<template>
  <div class="EmergencyList">
    <div class="flex location-wrap">
      <span class="white">当前位置：</span>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/TrainingPlan' }">培训演练</el-breadcrumb-item>
        <el-breadcrumb-item>培训计划</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="box">
      <!-- 列表筛选 -->
      <filterTitle @query="query" @reset="reset" :form="form" labelWidth="140px" :formData="formData"
        @node-click="deptChoose">
        <!-- <el-form slot="filter" class="form" ref="form" :model="form" inline size="small" label-width="140px">
          <el-form-item :label="item.label + '：'" v-for="(item, index) in formData" :key="index" :rules="rules[item.id]" :prop="item.id">
            <LsdForm :compData="item" :form="form" @node-click="deptChoose(arguments, item)" @change="selectChange(arguments, item)" />
          </el-form-item>
        </el-form> -->
      </filterTitle>
      <!-- 列表表格 -->
      <LsdTable slot="yjrwlb" :paginationAtrrs="table.paginationAtrrs" @pageChange="handleSizeChange"
        :compRef="table.compRef" ref="yjrwlb" :columns="table.columns" :title="table.title" :actions="table.actions"
        :tableData="table.tableData" :tableAttr="table.tableAttr" :isShowPage="table.isShowPage"
        :isSelectFlag="table.isSelectFlag" :isSequenceFlag="table.isSequenceFlag" @onActionClick="onActionClick" />
    </div>
    <LsdDialog :dialogConfig="dialogConfig" @handleBtn="handleBtn" @close="close">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig" :activeNames="activeNames">
        <DialogForm ref="formComponent" slot="slot1" :formConfig="formConfig" @handleNodeClick="handleNodeClick"
          @handleInput="handleInput" />
        <div slot="slot2">
          <el-table max-height="230px" stripe :header-cell-style="header_cell_style" border ref="multipleTable"
            :data="tables.tableData" tooltip-effect="dark" style="width: 100%" size="small">
            <el-table-column prop="trainingPeriod" label="培训期次" align="center" min-width="80px">
              <template slot-scope="scope">
                <span v-if="scope.row.trainingPeriod === 1">第1期</span>
                <span v-else-if="scope.row.trainingPeriod === 2">第2期</span>
              </template>
            </el-table-column>
            <el-table-column prop="planStartTime" align="center" label="计划开始时间" min-width="200px">
              <template slot-scope="scope">
                <div v-if="tableColumn === false">{{ scope.row.planStartTime }}</div>
                <el-date-picker v-else v-model="scope.row.planStartTime" @change="pickerChanges(scope.row, 1)"
                  value-format="yyyy-MM-dd" type="date" placeholder="请选择计划开始时间">
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column prop="planEndTime" align="center" label="计划完成时间" min-width="200px">
              <template slot-scope="scope">
                <div v-if="tableColumn === false">{{ scope.row.planEndTime }}</div>
                <el-date-picker v-else v-model="scope.row.planEndTime" @change="pickerChanges(scope.row, 0)"
                  value-format="yyyy-MM-dd" type="date" placeholder="请选择计划完成时间">
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column prop="trainingTargetUnit" label="培训单位" align="center" min-width="380px">
              <template slot-scope="scope">
                <div v-if="tableColumn === false">{{ scope.row.trainingTargetUnit }}</div>
                <DialogForm v-else :ref="`formComponentcy${scope.$index}`" @removeTag="removeTag" slot="slot2"
                  :formConfig="formConfigcy"
                  @treeInput="(value, data, node) => { treeInput(value, data, node, scope); }" />
              </template>
            </el-table-column>
            <el-table-column prop="planTrainingCount" label="计划培训人数" align="center" min-width="100px">
            </el-table-column>

          </el-table>
        </div>
        <DialogForm ref="formComponent1" slot="slot3" :formConfig="formConfig1" />
        <DialogForm ref="formComponents" slot="slot4" :formConfig="formConfigs" />
      </LsdDialogTitle>
    </LsdDialog>
    <LsdDialog :dialogConfig="dialogConfigbj" @handleBtn="handleBtn" @close="closebj">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfigbj" :activeNames="activeNamesbj">
        <DialogForm ref="formComponentbj" slot="slot1" :formConfig="formConfigbj" />
        <div slot="slot2">
          <el-table max-height="230px" stripe :header-cell-style="header_cell_style" border ref="multipleTable"
            :data="tablesbj.tableData" tooltip-effect="dark" style="width: 100%" size="small">
            <el-table-column prop="trainingPeriod" label="培训期次" align="center" min-width="80px">
              <template slot-scope="scope">
                <span v-if="scope.row.trainingPeriod === 1">第1期</span>
                <span v-else-if="scope.row.trainingPeriod === 2">第2期</span>
              </template>
            </el-table-column>
            <el-table-column prop="planStartTime" align="center" label="计划开始时间" min-width="200px">
              <template slot-scope="scope">
                <el-date-picker v-model="scope.row.planStartTime" @change="pickerChangesbj(scope.row, 1)"
                  value-format="yyyy-MM-dd" type="date" placeholder="请选择计划开始时间">
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column prop="planEndTime" align="center" label="计划完成时间" min-width="200px">
              <template slot-scope="scope">
                <el-date-picker v-model="scope.row.planEndTime" @change="pickerChangesbj(scope.row, 0)"
                  value-format="yyyy-MM-dd" type="date" placeholder="请选择计划完成时间">
                </el-date-picker>
              </template>
            </el-table-column>
            <el-table-column prop="trainingTargetUnit" label="培训单位" align="center" min-width="380px">
              <template slot-scope="scope">
                <DialogForm ref="formComponentcybj" @removeTag="removeTagbj" slot="slot2" :formConfig="formConfigcybj"
                  @treeInput="(value, data, node) => { treeInputbj(value, data, node, scope); }" />
              </template>
            </el-table-column>
            <el-table-column prop="planTrainingCount" label="计划培训人数" align="center" min-width="100px">
            </el-table-column>

          </el-table>
        </div>
        <DialogForm ref="formComponent1" slot="slot3" :formConfig="formConfig1" />
      </LsdDialogTitle>
    </LsdDialog>
    <!--下发弹窗 -->
    <LsdDialog :dialogConfig="dialogConfig1" @handleBtn="handleBtn1" @close="close1">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig1" :activeNames="activeNames1">
        <DialogForm ref="formComponent2" slot="slot1" :formConfig="formConfig2" />
        <DialogForm ref="formComponent3" slot="slot2" :formConfig="formConfig3" @handlePreview="handlePreview"
          @handleChange="handleChange" @handleBeforeUpload="handleBeforeUpload" @changeEvent="handleChangewz" />
        <div slot="slot2" v-show="attachNameshow">
          <div class="Download" style="text-indent:20px">
            附件：
          </div>
          <div class="Downloads" style="margin-left:-10px" v-for="(item, index) in attachInfo" :key="index"
            @click="handlePreview(item)">
            {{ item.attachName }}
          </div>
        </div>
        <div v-for="(item, index) in cydwList" slot="slot3" :key="index">
          <DialogForm :ref="item.ref" :formConfig="item.formConfig" />
        </div>
        <DialogForm ref="formComponent5" slot="slot4" :formConfig="formConfig5" />
        <DialogForm ref="formComponent7" slot="slot5" :formConfig="formConfig7" />
      </LsdDialogTitle>
    </LsdDialog>
    <!--人员上报 -->
    <LsdDialog :dialogConfig="dialogConfig2" @handleBtn="handleBtn2" @close="close2">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig2" :activeNames="activeNames2">
        <DialogForm ref="formComponent2" slot="slot1" :formConfig="formConfig2" />
        <DialogForm ref="formComponent3" slot="slot2" :formConfig="formConfig3"
          @handleBeforeUpload="handleBeforeUpload" />
        <div slot="slot2" v-show="attachNameshow">
          <div class="Download" style="text-indent:20px">
            附件：
          </div>
          <div class="Downloads" style="margin-left:-10px" v-for="(item, index) in attachInfo" :key="index"
            @click="handlePreview(item)">
            {{ item.attachName }}
          </div>
        </div>
        <div slot="slot3">
          <DialogForm v-show="personnelConfig.table.tableData.length === 0" ref="formComponent8"
            @getResourcesData="getResourcesData" :formConfig="formConfig8" />
          <div v-show="personnelConfig.table.tableData.length > 0"
            style="font-size:16px;margin-left:60px;color: #606266;">已选人员：{{ personnelConfig.table.tableData.length }}
          </div>
          <LsdTable v-show="personnelConfig.table.tableData.length > 0" :tableData="personnelConfig.table.tableData"
            :columns="personnelConfig.table.columns" :compRef="personnelConfig.table.compRef"
            :accesskey="personnelConfig.table.compRef" :title="personnelConfig.table.title"
            :autoHeight="personnelConfig.table.autoHeight" :actions="personnelConfig.table.actions"
            :tableAttr="personnelConfig.table.tableAttr" :isShowPage="personnelConfig.table.isShowPage"
            :isSelectFlag="personnelConfig.table.isSelectFlag" :isSequenceFlag="personnelConfig.table.isSequenceFlag" />
        </div>
        <DialogForm ref="formComponent5" slot="slot4" :formConfig="formConfig5" />
        <DialogForm ref="formComponent8" slot="slot5" :formConfig="formConfig8" />
      </LsdDialogTitle>
    </LsdDialog>
    <!-- 人员选择弹窗 -->
    <DialogChoose ref="dialogChoose" @checkSelect="checkSelect" @handleChooseChange="handleChooseChange"
      @chooseQuery="chooseQuery" :ChooseConfig="ChooseConfig" @close="close3" @teamAdd="teamAdd"
      :ChooseFormConfig="PersonnelFormConfig" :ChooseTableConfig="PersonnelTableConfig"></DialogChoose>
    <!--关联年计划 -->
    <LsdDialog :dialogConfig="dialogConfig3" @handleBtn="handleBtn3" @close="close4">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig3" :activeNames="activeNames3">
        <DialogForm ref="formComponent10" slot="slot1" :formConfig="formConfig10" />
        <div slot="slot1">
          <div class="Download">
            附件：
          </div>
          <div class="Downloads" v-for="(item, index) in attachInfo" :key="index" @click="handlePreview(item)">
            {{ item.attachName }}
          </div>
        </div>
      </LsdDialogTitle>
    </LsdDialog>
  </div>
</template>

<script>
// getListUser
import { trainingMonthlyListPage, trainingMonthlyInsert, getActuMembers, getOrgDepartmentList, trainingMonthlyExportMonthly, trainingMonthlyDetail, trainingMonthlyUpdate, trainingRecordAdd, trainingNoticeInsert, trainingNoticeDetail, getMembers, trainingDrillStaffInsertOrUpdate, trainingDrillStaffGetMembersByRefId, trainingDrillStaffUpdate } from "@/api/TrainingAndExercise/ydpxjh.js";
import { trainingYearlyList, trainingYearlyUpdate, trainingYearlyDetail } from "@/api/TrainingAndExercise/ndpxjh.js";
import { UploadFile, loadFile, GetByOrganization, dicList } from "@/api/common.js";
import { getUnitTreeApi } from "@/api/EarlyWarningManagement/yjrb";
import { formData } from "./config/Temporaryplan";
import { showTime } from "@/lib";
import common from "@/utils/common.js";
import { handleGetNextUsers } from "@/utils/flow";
export default {
  data() {
    return {
      monthlyBatchDtos: [],
      formData: formData,
      distinguish: 0,
      header_cell_style: {
        textAlign: "center",
        backgroundColor: "#B1C8F9",
        border: "1px solid #ccc",
        fontSize: "16px",
        color: "#333"
      },
      // 下发通知参演单位数组
      cydwList: [],
      tableColumn: true,
      table: {
        isSelectFlag: false,
        compRef: "yjrwlb",
        isSequenceFlag: true,
        isShowPage: true,
        resetFlag: true,
        loading: false,
        title: "临时培训计划列表",
        actions: [{
          id: "TemporaryplanAdd",
          text: "新增",
          type: "primary",
          btnAttr: { size: "small" }
        },
        // {
        //   id: "add",
        //   text: "导入",
        //   btnAttr: { size: "small" }
        // },
        {
          id: "onExport",
          text: "导出",
          btnAttr: { size: "small" }
        }],
        tableData: [],
        columns: [
          {
            prop: "associatedTrainingName",
            label: "关联年计划",
            align: "left",
            "min-width": "200px",
            render: (h, { row }) => {
              return (<div>
                {<span style='color:#3561fd;cursor:pointer;text-decoration: underline;' {...{
                  on: {
                    click: () => {
                      this.toTaskDetails(row.associatedTrainingId);
                    }
                  }
                }}>
                  {row.associatedTrainingName}
                </span>}
              </div>);
            }
          },
          {
            prop: "trainingProjectName",
            label: "培训项目",
            align: "left",
            "min-width": "160px"
          },
          {
            prop: "organisedUnitName",
            label: "主办单位",
            align: "center",
            "min-width": "160px"
          },
          {
            prop: "trainingContent",
            label: "培训内容",
            align: "left",
            "min-width": "220px"
          },
          {
            prop: "trainingTarget",
            label: "培训对象",
            align: "center",
            "min-width": "110px"
          },
          {
            prop: "trainingAddress",
            label: "培训地点",
            align: "left",
            "min-width": "80px"
          },
          {
            prop: "trainingPeriod",
            label: "培训期次",
            align: "center",
            formatter: (row, column, cellValue, index) => {
              if (cellValue !== null) {
                return `第${cellValue}期`;
              }
            }
          },
          {
            prop: "planTrainingCount",
            label: "计划培训人数",
            align: "center",
            "min-width": "70px"
          },
          {
            prop: "actualTrainingCount",
            label: "实际参培人数",
            align: "center",
            "min-width": "70px",
            render: (h, { row }) => {
              return (<div>
                {<span style='color:#3561fd;cursor:pointer;text-decoration: underline;' {...{
                  on: {
                    click: () => {
                      this.toActualTrainingCount(row.id);
                    }
                  }
                }}>
                  {row.actualTrainingCount}
                </span>}
              </div>);
            }
          },
          {
            prop: "planStartTime",
            label: "计划开始时间",
            align: "center",
            "min-width": "120px"
          },
          {
            prop: "planEndTime",
            label: "计划完成时间",
            align: "center",
            "min-width": "120px"
          },
          {
            prop: "stauts",
            label: "状态",
            align: "center",
            "min-width": "80px",
            formatter: (row, column, cellValue, index) => {
              if (cellValue === 0) {
                return "待编辑";
              } else if (cellValue === 3 || cellValue === 33 || cellValue === 36) {
                return "待审批";
              } else if (cellValue === 2) {
                return "已完成";
              } else if (cellValue === 6 || cellValue === 35 || cellValue === 39) {
                return "驳回";
              } else if (cellValue === 1 || cellValue === 34 || cellValue === 37) {
                return "编辑中";
              } else if (cellValue === 4) {
                return "待上报";
              } else if (cellValue === 38) {
                return "人员已上报";
              }
            }
          },
          {
            prop: "caozuo",
            label: "操作",
            align: "center",
            "min-width": "180px",
            render: (h, scope) => {
              let arr = [];
              const userId = JSON.parse(sessionStorage.getItem("account")).id;
              const tbPower = this.common.isHasPower("tbr");
              const spPower = this.common.isHasPower("spr");
              if ([0].includes(scope.row.stauts) && tbPower) {
                arr = ["编辑"];
              } else if (scope.row.stauts === 2 && scope.row.nextAssignee && scope.row.nextAssignee.includes(userId)) {
                arr = ["下发通知"];
              } else if (scope.row.stauts === 36 && spPower) {
                arr = ["审批"];
              } else if (scope.row.stauts === 3 && scope.row.nextAssignee && scope.row.nextAssignee.includes(userId)) {
                arr = ["审批"];
              } else if ([6, 1, 34, 35].includes(scope.row.stauts) && tbPower) {
                arr = ["编辑"];
              } else if ([37, 39].includes(scope.row.stauts) && tbPower) {
                arr = ["编辑"];
              } else if (scope.row.stauts === 33 && scope.row.nextAssignee && scope.row.nextAssignee.includes(userId)) {
                arr = ["通知审批"];
              } else if (scope.row.stauts === 4 && tbPower) {
                arr = ["人员反馈"];
              } else if (scope.row.stauts === 38 && tbPower) {
                const result = [
                  {
                    label: "查看结果",
                    abelValue: "上传结果",
                    value: "attachResultInfo"
                  },
                  {
                    label: "查看签到表",
                    abelValue: "签到表",
                    value: "attendanceSheetFile"
                  },
                  {
                    label: "查看成绩单",
                    abelValue: "成绩单",
                    value: "transcriptFile"
                  }
                ];
                result.map((i, index) => {
                  if (scope.row[i.value]) {
                    arr.push(i.label);
                  } else {
                    arr.push(i.abelValue);
                  }
                });
              }
              return (
                <div>
                  {
                    arr.map(item => {
                      return (
                        <span style='color:#3561fd;cursor:pointer;margin:0 2px' {...{
                          on: {
                            click: () => {
                              this.actionHandle(item, scope);
                            }
                          }
                        }}>
                          {item}
                        </span>
                      );
                    })
                  }
                </div >
              );
            }
          }
        ],
        tableAttr: {
          "max-height": "430px",
          height: "430px",
          border: true,
          fit: true,
          stripe: true,
          "show-header": true,
          "highlight-current-row": true,
          "cell-style": {
            "font-size": "16px"
          },
          "header-cell-style": {
            "text-align": "center",
            "background-color": "#B1C8F9",
            border: "1px solid #ccc",
            "font-size": "16px"
          }
        },
        // 分页信息
        paginationAtrrs: {
          total: 0,
          "background": true,
          layout: "prev, pager, next",
          "current-page": 1,
          "page-size": 10
        }
      },
      type: 0,
      tables: {
        tableData: [
          // { trainingPeriod: 1 }
        ]
      },
      tablesbj: {
        tableData: [
          { trainingPeriod: "", planStartTime: "", planEndTime: "", trainingTargetUnit: "", planTrainingCount: "" }
        ]
      },
      form: {},
      config: {},
      rules: [],
      pageNum: 1,
      pageSize: 10,
      dialogConfig: {
        title: "临时培训计划",
        isShow: false, // 弹窗显示隐藏
        btnList: [

        ]
      },
      dialogConfigbj: {
        title: "临时培训计划",
        isShow: false, // 弹窗显示隐藏
        btnList: [

        ]
      },
      // 弹窗信息
      dialogConfig1: {
        title: "培训通知",
        isShow: false, // 弹窗显示隐藏
        btnList: [

        ]
      },
      // 人员上报弹窗信息
      dialogConfig2: {
        title: "人员上报",
        isShow: false, // 弹窗显示隐藏
        btnList: []
      },
      // 关联年计划弹窗信息
      dialogConfig3: {
        title: "关联年计划",
        isShow: false, // 弹窗显示隐藏
        btnList: [
          {
            id: "returnFalse",
            name: "返回",
            type: "primary",
            size: "mini"
          }
        ]
      },
      activeNames: ["1", "2", "3", "4"], // 折叠面板默认展开列
      activeNamesbj: ["1", "2", "3", "4"], // 折叠面板默认展开列
      activeNames1: ["1", "2", "3", "4", "5"], // 折叠面板默认展开列
      activeNames2: ["1", "2", "3", "4", "5"], // 人员上报折叠面板默认展开列
      activeNames3: ["1", "2", "3", "4", "5"], // 关联年计划折叠面板默认展开列
      // 折叠面板信息
      titleConfig: [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "培训明细信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "填报信息",
          name: "3",
          slot: "slot3"
        }
      ],
      // 折叠面板信息
      titleConfigbj: [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "培训明细信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "填报信息",
          name: "3",
          slot: "slot3"
        }
      ],
      // 折叠面板信息
      titleConfig1: [],
      // 人员上报
      titleConfig2: [],
      // 关联年计划
      titleConfig3: [
        {
          title: "年度培训信息",
          name: "1",
          slot: "slot1"
        }
      ],
      // 弹窗表单信息
      formConfig: {
        formData: [

        ],
        rules: {

        }
      },
      // 弹窗表单信息
      formConfigbj: {
        formData: [

        ],
        rules: {

        }
      },
      // 弹窗表单信息
      formConfig1: {
        formData: [
          {
            type: "input",
            label: "填报人",
            prop: "creator",
            isDisabled: true,
            class: "third",
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "单位及部门",
            class: "third",
            isDisabled: true,
            prop: "creatorUnit",
            lableWidth: "130px"
          },
          {
            type: "input",
            label: "填报时间",
            class: "third",
            isDisabled: true,
            prop: "createTime",
            lableWidth: "130px"
          }
        ]
      },
      formConfigs: {
        formData: [{
          type: "input",
          label: "审批意见",
          isDisabled: false,
          prop: "approvalOpinion",
          class: "sjgy",
          lableWidth: "120px"
        },
        {
          type: "input",
          label: "审批人",
          isDisabled: true,
          prop: "approvalUser",
          class: "third",
          lableWidth: "120px"
        },
        {
          type: "input",
          label: "单位及部门",
          isDisabled: true,
          class: "third",
          prop: "approvalDept",
          lableWidth: "120px"
        },
        {
          type: "input",
          label: "审批时间",
          isDisabled: true,
          class: "third",
          prop: "approvalTime",
          lableWidth: "120px"
        }]
      },
      formConfig2: {
        formData: [
          {
            type: "input",
            label: "主办单位",
            prop: "organisedUnitName",
            name: "warningLvName",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "dataPicker",
            label: "培训时间",
            prop: "trainingStartTimes",
            isDisabled: false,
            start: "trainStartTime",
            end: "trainEndTime",
            class: "half",
            pickerType: "date",
            dateType: "datetimerange",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训项目",
            prop: "trainingProjectName",
            name: "dangerName",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },

          {
            type: "input",
            label: "培训对象",
            prop: "trainingTarget",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          }
        ]
        // rules: {
        //   trainingStartTimes: [
        //     { required: true, message: "请选择培训时间", trigger: "bur" }
        //   ]
        // }
      },
      formConfig3: {},
      formConfig4: {
        formData: [

        ]
      },
      // 弹窗表单信息
      formConfig5: {
        formData: [
          {
            type: "input",
            label: "填报人",
            prop: "creator",
            isDisabled: true,
            class: "third",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "单位及部门",
            class: "third",
            isDisabled: true,
            prop: "creatorUnit",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "填报时间",
            class: "third",
            isDisabled: true,
            prop: "createTime",
            lableWidth: "140px"
          }
        ]
      },
      formConfig8: {
        formData: [
          {
            type: "btnInput",
            label: "人员上报",
            prop: "fillUser",
            noBorder: true,
            hidden: false,
            class: "third",
            value: "请选择",
            lableWidth: "140px"
          }
        ]
      },
      // 弹窗表单信息
      formConfig9: {},
      // 弹窗表单信息
      formConfig10: {
        formData: [
          {
            type: "input",
            label: "培训项目",
            prop: "trainingProjectName",
            isDisabled: true,
            class: "half",
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "主办单位",
            prop: "organisedUnitName",
            isDisabled: true,
            class: "half",
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "培训对象",
            prop: "trainingTarget",
            isDisabled: true,
            class: "half",
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "计划类型",
            prop: "projectType",
            isDisabled: true,
            class: "half",
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "培训总期次",
            prop: "trainingPeriod",
            isDisabled: true,
            class: "half",
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "计划完成时间",
            prop: "planCompleteTime",
            isDisabled: true,
            class: "half",
            lableWidth: "120px"
          },
          {
            type: "textarea",
            label: "培训年度",
            prop: "trainingYearly",
            isDisabled: true,
            class: "sjgy",
            lableWidth: "120px"
          },
          {
            type: "textarea",
            label: "培训内容",
            prop: "trainingContent",
            isDisabled: true,
            class: "sjgy",
            lableWidth: "120px"
          }
        ]
      },
      // 人员选择弹窗信息
      ChooseConfig: {
        title: "人员选择",
        isShow: false,
        checkSelect: true,
        type: "",
        btnList: [
          {
            id: "confirm",
            name: "确认",
            type: "primary",
            size: "mini"
          },
          {
            id: "cancel",
            name: "取消",
            size: "mini"
          }
        ],
        index: 0,
        unit: "名人员"
      },
      // 人员选择
      PersonnelFormConfig: {
        formData: [
          {
            type: "input",
            label: "姓名",
            prop: "name",
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "select",
            label: "人员性质",
            prop: "memberType",
            // name: "memberType",
            dic: "memberType",
            class: "half",
            lableWidth: "140px",
            option: [
              // {
              //   label: "主业",
              //   value: "主业"
              // },
              // {
              //   label: "副业",
              //   value: "副业"
              // }
            ]
          },
          {
            type: "select",
            label: "人员专业",
            prop: "memberMajor",
            dic: "memberMajor",
            class: "half",
            lableWidth: "140px",
            option: []
          },
          {
            type: "selectTree",
            label: "所属单位及部门",
            prop: "accessUnit",
            name: "accessUnitId",
            title: "所属单位及部门选择",
            keyWord: "units5", // 搜索关键字，同一表单需要绑定唯一值
            treeRef: "unitRef5", // 树结构绑定的ref，同一表单需绑定唯一值
            commonClick: true, // 是否使用默认点击事件，
            clickClose: false, // 判断是否点击选择单位后是否立刻关闭弹窗，
            choose: false, // 判断是否可以多选
            ref: "unit_select5", // 同一表单需要绑定唯一ref，用于关闭对应弹窗
            class: "half",
            lableWidth: "140px",
            treeData: {
              data: [],
              default: ["1"],
              checked: [],
              props: {
                children: "children",
                label: "orgName",
                value: "id"
              }
            }
          }
        ]
      },
      PersonnelTableConfig: {
        isSelectFlag: true,
        compRef: "playerTabel",
        isSequenceFlag: true,
        isShowPage: false,
        resetFlag: false,
        loading: false,
        autoHeight: true,
        title: "",
        selectColumnAttr: {
          // "reserve-selection": true,
          // "selectable": (row) => {
          //   return row.occupation === 1;
          // }
        },
        tableData: [],
        columns: [
          {
            prop: "unit",
            label: "所属单位及部门",
            align: "center"
          },
          {
            prop: "name",
            label: "姓名",
            align: "center"
          },
          {
            prop: "contactWay",
            label: "联系方式",
            align: "center"
          },
          {
            prop: "memberType",
            label: "人员性质",
            align: "center"
          },
          {
            prop: "professional",
            label: "人员专业",
            align: "center"
          },
          {
            prop: "trainingCount",
            label: "参与培训次数",
            align: "center"
          },
          {
            prop: "trainingProjectName",
            label: "参与培训项目",
            align: "center"
          },
          {
            prop: "entryTime",
            label: "入岗时间",
            align: "center"
          }
        ],
        tableAttr: {
          "row-key": "id",
          // "max-height": "550px",
          // "height": "400px",
          "stripe": false,
          "border": true,
          "fit": true,
          "show-header": true,
          "highlight-current-row": false,
          "cell-style": {
            "font-size": "16px"
          },
          "header-cell-style": {
            "text-align": "center",
            "background-color": "#B1C8F9",
            "border": "1px solid #ccc",
            "font-size": "16px"
          }
        },
        // 分页信息
        paginationAtrrs: {
          total: 0,
          "background": true,
          layout: "prev, pager, next",
          "current-page": 1,
          "page-size": 10
        }
      },
      // 选择人员后
      personnelConfig: {
        table: {
          isSelectFlag: false,
          compRef: "yxry",
          isSequenceFlag: true,
          autoHeight: true,
          isShowPage: false,
          resetFlag: false,
          loading: false,
          title: "",
          tableData: [],
          columns: [
            {
              prop: "unit",
              label: "所属单位及部门",
              align: "center"
            },
            {
              prop: "name",
              label: "姓名",
              align: "center"
            },
            {
              prop: "contactWay",
              label: "联系方式",
              align: "center"
            },
            {
              prop: "memberType",
              label: "人员性质",
              align: "center"
            },
            {
              prop: "professional",
              label: "人员专业",
              align: "center"
            },
            {
              prop: "trainingCount",
              label: "参与培训次数",
              align: "center"
            },
            {
              prop: "trainingProjectName",
              label: "参与培训项目",
              align: "center"
            },
            {
              prop: "entryTime",
              label: "入岗时间",
              align: "center"
            }
          ],
          tableAttr: {
            // "max-height": "550px",
            "stripe": false,
            "border": true,
            "fit": true,
            "show-header": true,
            "highlight-current-row": false,
            "cell-style": {
              "font-size": "16px"
            },
            "header-cell-style": {
              "text-align": "center",
              "background-color": "#B1C8F9",
              "border": "1px solid #ccc",
              "font-size": "16px"
            }
          }
        }
      },
      // 弹窗表单信息
      formConfig7: {},
      FilledBy: {},
      fid: "",
      IssuedId: "", // 下发id
      // 弹窗表单信息
      formConfigcy: {
        formData: [{
          type: "selectTree",
          // label: "参演单位",
          prop: "trainingTargetUnit",
          name: "trainingTargetUnitId",
          keyWord: "keyWord3",
          treeRef: "treeRef3",
          clickClose: true,
          title: "培训单位选择",
          choose: true,
          ref: "tree_select3",
          class: "sjgy",
          multiple: true,
          lableWidth: "140px",
          option: [],
          treeData: {
            data: [],
            default: ["1"],
            checked: [],
            props: {
              children: "children",
              label: "orgName",
              value: "id"
            }
          }
        }]
      },
      // 弹窗表单信息
      formConfigcybj: {
        formData: [{
          type: "selectTree",
          // label: "参演单位",
          prop: "trainingTargetUnit",
          name: "trainingTargetUnitId",
          title: "培训单位选择",
          keyWord: "keyWord",
          treeRef: "treeRef",
          clickClose: true,
          choose: true,
          ref: "tree_select2",
          class: "sjgy",
          multiple: true,
          lableWidth: "140px",
          option: [],
          treeData: {
            data: [],
            default: ["1"],
            // checked: ["1516830294278176"],
            props: {
              children: "children",
              label: "orgName",
              value: "id"
            }
          }
        }]
      },
      fileSize: "",
      trainingTargetUnit0: [],
      trainingTargetUnitId0: [],
      trainingTargetUnit1: [],
      trainingTargetUnitId1: [],
      attachInfo: [],
      attachNameshow: false
    };
  },
  mounted() {
    this.list();
    this.getInputVal();
    // this.getUnitTree();
    this.getSerchTree();
    const FilledBy = {
      creator: JSON.parse(sessionStorage.getItem("account")).realName,
      creatorId: JSON.parse(sessionStorage.getItem("account")).id,
      deptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
      creatorUnit: sessionStorage.getItem("dwbmName"),
      createTime: showTime(new Date()),
      approvalUserId: JSON.parse(sessionStorage.getItem("account")).id,
      approvalUser: JSON.parse(sessionStorage.getItem("account")).realName,
      pprovalDeptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
      approvalDept: sessionStorage.getItem("dwbmName"),
      approvalTime: showTime(new Date())
    };
    this.FilledBy = FilledBy;
  },
  methods: {
    async Shchan(id, val) {
      console.log("llll");
      try {
        let file = await this.pick(".pdf,.jpg,.png,.pdf,.doc", true);
        const maxFileSize = 20 * 1024 * 1024;
        let flag = true;
        if (file[0].fileSize > maxFileSize) {
          this.$message({
            message: "上传文件大小不得大于20MB!",
            type: "error"
          });
          file = [];
          flag = false;
        }
        if (flag) {
          console.log("4444444444444444");
          const parmas = {
            file: file[0],
            directoryId: 0,
            isNew: false,
            moduleName: "plan_training"
          };
          UploadFile(this.common.convertFormData(parmas)).then(data => {
            const attachInfo = [
              {
                attachName: data.fileName,
                attachId: data.id
              }
            ];
            let pasams = {};
            if (val === 1) {
              pasams = {
                id: id.id,
                attachResultInfo: JSON.stringify(attachInfo) // 上传结果
              };
            } else if (val === 2) {
              pasams = {
                id: id.id,
                attendanceSheetFile: JSON.stringify(attachInfo) // 成绩单
              };
            } else if (val === 3) {
              pasams = {
                id: id.id,
                transcriptFile: JSON.stringify(attachInfo) // 签到表
              };
            }
            trainingMonthlyUpdate(pasams).then(res => {
              if (res) {
                this.$message({
                  message: "上传成功",
                  type: "success"
                });
                this.list();
              } else {
                this.$message({
                  message: "文件格式不对",
                  type: "error"
                });
              }
            });
          });
        }
      } catch (error) {
        console.log(error);
      }
    },
    // 查看上传结果
    TrainingDetails(id, val) {
      if (val === 1) {
        if (id.attachResultInfo) {
          // 上传结果
          const attachResultInfo = JSON.parse(id.attachResultInfo);
          // console.log(attachResultInfo, "attachResultInfoattachResultInfo");
          // loadFile({ id: attachResultInfo[0].attachId }).then(data => {
          //   window.open(data);
          // });
          const loading = this.$loading({
            lock: true,
            text: "Loading",
            spinner: "el-icon-loading",
            background: "rgba(0, 0, 0, 0.6)"
          });
          loadFile({ id: attachResultInfo[0].attachId }).then(res => {
            const a = document.createElement("a");
            const objectUrl = URL.createObjectURL(res);
            a.setAttribute("href", objectUrl);
            a.setAttribute("download", attachResultInfo[0].attachName);
            a.click();
            loading.close();
          }).catch(() => {
            loading.close();
          });
        }
      } else if (val === 2) {
        if (id.attendanceSheetFile) {
          // 成绩单
          const attachResultInfo = JSON.parse(id.attendanceSheetFile);
          const loading = this.$loading({
            lock: true,
            text: "Loading",
            spinner: "el-icon-loading",
            background: "rgba(0, 0, 0, 0.6)"
          });
          loadFile({ id: attachResultInfo[0].attachId }).then(res => {
            const a = document.createElement("a");
            const objectUrl = URL.createObjectURL(res);
            a.setAttribute("href", objectUrl);
            a.setAttribute("download", attachResultInfo[0].attachName);
            a.click();
            loading.close();
          }).catch(() => {
            loading.close();
          });
        }

      } else if (val === 3) {
        if (id.transcriptFile) {
          // 签到表
          const attachResultInfo = JSON.parse(id.transcriptFile);
          const loading = this.$loading({
            lock: true,
            text: "Loading",
            spinner: "el-icon-loading",
            background: "rgba(0, 0, 0, 0.6)"
          });
          loadFile({ id: attachResultInfo[0].attachId }).then(res => {
            const a = document.createElement("a");
            const objectUrl = URL.createObjectURL(res);
            a.setAttribute("href", objectUrl);
            a.setAttribute("download", attachResultInfo[0].attachName);
            a.click();
            loading.close();
          }).catch(() => {
            loading.close();
          });
        }
      }

    },
    // 弹窗按钮点击事件 对应id绑定事件 关联年计划弹窗
    handleBtn3(item) {
      this[item.id]();
    },
    // 实际培训人数弹窗
    toActualTrainingCount(id) {
      this.ChooseConfig.isShow = true;
      getActuMembers({ trainId: id }).then(res => {
        this.PersonnelTableConfig.isSelectFlag = false;
        this.PersonnelTableConfig.isSequenceFlag = false;
        this.ChooseConfig.unit = "";
        this.PersonnelTableConfig.tableData = res;
        this.PersonnelTableConfig.paginationAtrrs.total = res.length;

      });
    },
    // 参培单位
    treeInputbj(value, data, node) {
      if (this.dialogConfigbj.isShow === true) {
        data.porgName = value;
        const result = this.$refs.formComponentcybj.form.trainingTargetUnitId;
        const result1 = this.$refs.formComponentcybj.form.trainingTargetUnit;
        if (result.length > 0) {
          if (result.indexOf(data.id) === -1) {
            this.$refs.formComponentcybj.form.trainingTargetUnit.push(`${data.orgName}(${data.porgName})`);
            this.$refs.formComponentcybj.form.trainingTargetUnitId.push(data.id);
          } else {
            const toBeDeleted = []; // 需要删除的下标记录
            result.forEach((item, index) => {
              if (item === data.id) {
                console.log(value);
                if (!value) {
                  toBeDeleted.push(index); // 记录需要删除的下标
                } else {
                  result1[index] = `${data.orgName}(${data.porgName})`;
                  this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnit", result1);
                  this.$set(this.$refs.formComponentcybj.form.trainingTargetUnit, index, `${data.orgName}(${data.porgName})`);
                }
              }
            });
            // 遍历完成后进行删除操作
            if (toBeDeleted.length > 0) {
              this.$nextTick(() => {
                toBeDeleted.reverse().forEach((index) => { // 从后向前删除，避免下标变化导致的错误
                  result.splice(index, 1);
                  result1.splice(index, 1);
                });
                this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnitId", result);
                this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnit", result1);
              });
            }
          }
        } else {
          this.$refs.formComponentcybj.form.trainingTargetUnit.push(`${data.orgName}(${data.porgName})`);
          this.$refs.formComponentcybj.form.trainingTargetUnitId.push(data.id);
        }
        const num = this.$refs.formComponentcybj.form.trainingTargetUnit;
        console.log(this.$refs.formComponentcybj.form, "this.$refs.formComponentcybj.formthis.$refs.formComponentcybj.form");
        if (num.length > 0) {
          let pepol = 0;
          this.tablesbj.tableData[0].planTrainingCount = 0; // 每次统计数组 都先清零
          num.map(i => {
            const index = i.lastIndexOf("\(");
            pepol = i.substring(index + 1, i.length).slice(0, i.substring(index + 1, i.length).length - 1);
            this.tablesbj.tableData[0].planTrainingCount += Number(pepol);
          });

        }
      }
    },
    // 移除一项操作
    removeTagbj(val) {
      const index = val.lastIndexOf("\(");
      const pepol = val.substring(index + 1, val.length).slice(0, val.substring(index + 1, val.length).length - 1);
      this.tablesbj.tableData[0].planTrainingCount = Number(this.tablesbj.tableData[0].planTrainingCount) - Number(pepol);
    },
    // 根据联系人带出联系方式
    handleChangewz(val, item) {
      if (item.label === "联系人") {
        item.option.map(f => {
          if (f.value === val) {
            if (f.phone) {
              this.$set(this.$refs.formComponent3.form, "contactWay", f.phone);
            } else {
              this.$set(this.$refs.formComponent3.form, "contactWay", "");
            }
          }
        });
      }
    },
    returnFalse() {
      this.close4();
    },
    pick(accept, multiple) {
      return new Promise(function (resolve, reject) {
        const input = document.createElement("input");
        accept = accept ? accept.trim() : "";
        input.type = "file";
        input.multiple = multiple;
        let count = 0;
        function hasSelectedFile() {
          if (input.value !== "") {
            resolve(multiple ? Array.from(input.files) : input.files[0]);
          } else if (++count >= 40) {
            reject("pick cancel");
          } else {
            setTimeout(hasSelectedFile, 50);
          }
        }
        function focus() {
          window.removeEventListener("focus", focus);
          hasSelectedFile();
        }
        window.addEventListener("focus", focus);
        input.onchange = focus;
        input.accept = accept;
        input.click();
      });
    },
    // 弹窗关闭图标 关联年计划弹窗
    close4() {
      this.dialogConfig3.isShow = false;
    },
    // 根据选择的期次改变列表的数据
    handleInput(val, item) {
      if (item.label === "培训总期次") {
        this.tables.tableData = [];
        for (let i = 1; i <= val; i++) {
          this.tables.tableData.push({ trainingPeriod: i, planTrainingCount: Number("") });
        }
      }
    },
    // 导出操作
    onExport() {
      trainingMonthlyExportMonthly().then(res => {
        common.downloadByBlob(res, `临时培训计划列表${new Date().getTime()}.xlsx`);
      });
    },
    // 联系人
    GetByOrganization() {
      this.formConfig3.formData.forEach((item) => {
        if (item.label === "联系人") {
          GetByOrganization({ orgId: JSON.parse(sessionStorage.getItem("org")).orgId }).then(res => {
            const option = res.map((item) => {
              // const phone = item.phone === null ? "" : `：(${item.phone})`;
              return {
                label: `${item.realName}`,
                value: item.userId,
                phone: item.phone
              };
            });
            item.option = option;
          });
        }
      });
    },
    // 检索
    async query() {

      let parmas = {};
      if (this.form.planCompleteTime) {
        parmas = {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          trainingProjectName: this.form.trainingProjectName,
          trainingContent: this.form.trainingContent,
          trainingTarget: this.form.trainingTarget,
          trainingYearly: this.form.trainingYearly,
          stauts: this.form.stauts,
          planCompleteTime: this.form.planCompleteTime ? this.form.planCompleteTime : "",
          // planStartTime: this.form.planStartTime ? this.form.planStartTime : "",
          organisedUnitId: this.orgId,
          associatedTrainingId: this.form.associatedTrainingId,
          projectType: 3
        };
      } else if (this.form.planStartTime) {
        parmas = {
          pageNum: this.pageNum,
          pageSize: this.pageSize,
          trainingProjectName: this.form.trainingProjectName,
          trainingContent: this.form.trainingContent,
          trainingTarget: this.form.trainingTarget,
          trainingYearly: this.form.trainingYearly,
          stauts: this.form.stauts,
          // planCompleteTime: this.form.planCompleteTime ? this.form.planCompleteTime : "",
          planStartTime: this.form.planStartTime ? this.form.planStartTime : "",
          organisedUnitId: this.orgId,
          associatedTrainingId: this.form.associatedTrainingId,
          projectType: 3
        };
      }
      const res = await trainingMonthlyListPage(parmas);
      this.table.tableData = res.data;
      this.table.paginationAtrrs.total = res.total;
    },
    // 重置
    reset() {
      this.form = this.$options.data().form;
      this.$refs.yjrwlb.paginationAtrrsInner["current-page"] = 1;
      this.list();
    },
    // 参培单位
    treeInput(value, data, node, scope) {
      if (this.dialogConfig.isShow === true) {
        data.porgName = value;
        const result = this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnitId || [];
        const result1 = this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnit;
        if (result.length > 0) {
          if (result.indexOf(data.id) === -1) {
            this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnit.push(`${data.orgName}(${data.porgName})`);
            this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnitId.push(data.id);
          } else {
            const toBeDeleted = []; // 需要删除的下标记录
            result.forEach((item, index) => {
              if (item === data.id) {
                console.log(value);
                if (!value) {
                  toBeDeleted.push(index); // 记录需要删除的下标
                } else {
                  result1[index] = `${data.orgName}(${data.porgName})`;
                  this.$set(this.$refs[`formComponentcy${scope.$index}`].form, "trainingTargetUnit", result1);
                  this.$set(this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnit, index, `${data.orgName}(${data.porgName})`);
                }

              }
            });
            // 遍历完成后进行删除操作
            if (toBeDeleted.length > 0) {
              this.$nextTick(() => {
                toBeDeleted.reverse().forEach((index) => { // 从后向前删除，避免下标变化导致的错误
                  result.splice(index, 1);
                  result1.splice(index, 1);
                });
                this.$set(this.$refs[`formComponentcy${scope.$index}`].form, "trainingTargetUnitId", result);
                this.$set(this.$refs[`formComponentcy${scope.$index}`].form, "trainingTargetUnit", result1);
              });
            }
          }
        } else {
          this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnitId = [];
          this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnit = [];
          this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnit.push(`${data.orgName}(${data.porgName})`);
          this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnitId.push(data.id);
          if (scope.$index) {
            this.trainingTargetUnitId1.push(data.id);
            this.trainingTargetUnit1.push(`${data.orgName}(${data.porgName})`);
          } else {
            this.trainingTargetUnitId0.push(data.id);
            this.trainingTargetUnit0.push(`${data.orgName}(${data.porgName})`);
          }
        }
        const num = this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnit;
        if (num.length > 0) {
          let pepol = 0;
          this.tables.tableData[`${scope.$index}`].planTrainingCount = 0; // 每次统计数组 都先清零
          num.map(i => {
            const index = i.lastIndexOf("\(");
            pepol = i.substring(index + 1, i.length).slice(0, i.substring(index + 1, i.length).length - 1);
            this.tables.tableData[`${scope.$index}`].planTrainingCount += Number(pepol);
          });

        }
        this.tables.tableData[scope.$index].trainingTargetUnitId = this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnitId.join(",");
        this.tables.tableData[scope.$index].trainingTargetUnit = this.$refs[`formComponentcy${scope.$index}`].form.trainingTargetUnit.join(",");
      }
    },
    // 移除一项操作
    removeTag(val) {
      const index = val.lastIndexOf("\(");
      const pepol = val.substring(index + 1, val.length).slice(0, val.substring(index + 1, val.length).length - 1);
      this.tables.tableData.forEach((item, index) => {
        this.tables.tableData[`${index}`].planTrainingCount = Number(this.tables.tableData[`${index}`].planTrainingCount) - Number(pepol);
      });

    },
    // 树状接口
    getUnitTree() {
      getUnitTreeApi().then(res => {
        // this.formConfigcy.formData[0].treeData.data = res;
        // this.formConfigcybj.formData[0].treeData.data = res;

        this.formData[0].treeData.attrs.data = res;
        // this.formConfig.formData[0].treeData.data = res;
      });
      getOrgDepartmentList({ orgId: JSON.parse(sessionStorage.getItem("org")).orgId }).then(data => {
        this.formConfigcy.formData[0].treeData.data = data;
        this.formConfigcybj.formData[0].treeData.data = data;
        this.PersonnelFormConfig.formData[3].treeData.data = data;
        this.formConfig.formData[0].treeData.data = data;
      });
    },
    // 列表查询树状接口
    getSerchTree() {
      getUnitTreeApi().then(res => {
        this.formData[0].treeData.attrs.data = res;
      });
    },
    // 抛出列表按钮
    onActionClick(item, index) {
      this[item.id](); // 调用按钮对应方法
    },
    // 弹窗按钮点击事件 对应id绑定事件
    handleBtn(item) {
      this[item.id]();
    },
    // 下发通知弹窗按钮事件
    handleBtn1(item) {
      this[item.id]();
    },
    // 删除
    // handleRemove(file, fileList) {
    //   this.$set(this.$refs.formComponent1, "fileList", fileList);
    // },
    // 下载
    handlePreview(item) {
      const loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.6)"
      });
      loadFile({ id: item.attachId }).then(res => {
        const a = document.createElement("a");
        const objectUrl = URL.createObjectURL(res);
        a.setAttribute("href", objectUrl);
        a.setAttribute("download", item.attachName);
        a.click();
        loading.close();
      }).catch(() => {
        loading.close();
      });
    },
    handleChange(event) {
      this.fileSize = event.size; // 获取文件大小
    },
    // 上传附件
    handleBeforeUpload(file) {
      const maxFileSize = 20 * 1024 * 1024;
      let flag = true;
      if (this.fileSize > maxFileSize) {
        this.$message({
          message: "上传文件大小不得大于20MB!",
          type: "error"
        });
        this.$refs.formComponent3.fileList = [];
        flag = false;
      }
      if (flag) {
        const parmas = {
          file: file,
          directoryId: 0,
          isNew: false,
          moduleName: "plan_training"
        };
        UploadFile(this.common.convertFormData(parmas)).then(data => {
          this.$nextTick(() => {
            this.$refs.formComponent3.fileList.push({ name: data.fileName, attachId: data.id });
          });
        });
      }
    },
    // 下发通知弹窗
    close1() {
      this.$refs.formComponent3.fileList = [];
      this.cydwList = [];
      this.$refs.formComponent3.form = this.$refs.formComponent3.$options.data().form;
      this.$nextTick(() => {
        this.$refs.formComponent3.$refs.formInlines.clearValidate();
      });
      this.dialogConfig1.isShow = false;
    },
    // 下发和下发保存
    async submit() {
      let parmas = {};
      let parmass = {};
      const flowObj = {
        bizKey: this.fid,
        flowKey: "plan_001",
        taskId: "task1",
        idea: "1",
        ideaMsg: ""
      };
      this.$refs.formComponent3.isValidate();
      const flag = this.$refs.formComponent3.flag;
      let emptFlag = true;
      const newTableData = this.cydwList;
      newTableData.map((item, index) => {
        if (this.$refs[item.ref][0].form.receiverId === "" || this.$refs[item.ref][0].form.receiverId === null || this.$refs[item.ref][0].form.receiverId === undefined) {
          this.$message({
            message: `接收人，第${index + 1}条不能为空`,
            type: "error"
          });
          emptFlag = false;
        }
      });
      if (flag && emptFlag) {
        const list = this.$refs.formComponent3.fileList;
        const attachInfo = [];
        list.forEach(item => {
          attachInfo.push(
            {
              attachName: item.name,
              attachId: item.attachId
            }
          );
        });
        parmas = {
          noticeName: this.$refs.formComponent3.form.noticeName,
          contact: this.$refs.formComponent3.form.contactName,
          trainingAddress: this.$refs.formComponent3.form.trainingAddress,
          contactWay: this.$refs.formComponent3.form.contactWay,
          trainingCost: this.$refs.formComponent3.form.trainingCost,
          requirements: this.$refs.formComponent3.form.requirements,
          attachInfo: JSON.stringify(attachInfo),
          yearPlanId: this.fid,
          id: this.IssuedId,
          creator: JSON.parse(sessionStorage.getItem("account")).realName,
          creatorId: JSON.parse(sessionStorage.getItem("account")).id,
          // deptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
          creatorUnit: sessionStorage.getItem("dwbmName")
        };
        parmass = {
          approvalUserId: JSON.parse(sessionStorage.getItem("account")).id,
          approvalUser: JSON.parse(sessionStorage.getItem("account")).realName,
          approvalDeptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
          approvalDept: sessionStorage.getItem("dwbmName"),
          approvalType: "02",
          refId: this.fid
        };
        if (this.type === "Issued") {
          flowObj.taskId = "task3";
          flowObj.idea = "1";
          const nextAssigneeList = await handleGetNextUsers(flowObj);
          parmas = { ...parmas, ...flowObj, nextAssigneeList };
          trainingNoticeInsert(parmas).then(res => {
            const receiverId = [];
            const receiver = [];
            this.cydwList.map(item => {
              receiverId.push(this.$refs[item.ref][0].form.receiverId);
              receiver.push(this.$refs[item.ref][0].form.receiver);
            });
            let obj = {
              id: this.fid,
              trainStartTime: this.$refs.formComponent2.form.trainStartTime, // 开始时间
              trainEndTime: this.$refs.formComponent2.form.trainEndTime, // 结束时间
              stauts: 33,
              receiverIds: receiverId.join(","),
              receivers: receiver.join(",")
            };
            obj = { ...obj, ...flowObj, nextAssigneeList };
            trainingMonthlyUpdate(obj).then(data => {
              this.$message({
                message: "下发成功",
                type: "success"
              });
              this.list();
              this.dialogConfig1.isShow = false;
            });
          });
        } else if (this.type === "IssuingAndSaving") {
          trainingNoticeInsert(parmas).then(res => {
            const receiverId = [];
            const receiver = [];
            this.cydwList.map(item => {
              receiverId.push(this.$refs[item.ref][0].form.receiverId);
              receiver.push(this.$refs[item.ref][0].form.receiver);
            });
            trainingMonthlyUpdate({
              id: this.fid,
              trainStartTime: this.$refs.formComponent2.form.trainStartTime, // 开始时间
              trainEndTime: this.$refs.formComponent2.form.trainEndTime, // 结束时间
              stauts: 34,
              receiverIds: receiverId.join(","),
              receivers: receiver.join(",")
            }).then(data => {
              this.$message({
                message: "保存成功",
                type: "success"
              });
              this.list();
              this.dialogConfig1.isShow = false;
            });
          });
        } else if (this.type === "IssuedForApproval") {
          parmass.approvalSign = "pass";
          parmass.approvalOpinion = this.$refs.formComponent7.form.approvalOpinion;
          flowObj.taskId = "task4";
          flowObj.idea = "1";
          parmas.stauts = 4;
          parmas.id = this.fid;
          const nextAssigneeList = await handleGetNextUsers(flowObj);
          parmas = { ...parmas, ...flowObj, nextAssigneeList };
          trainingRecordAdd(parmass).then(res => {
            trainingMonthlyUpdate(parmas).then(data => {
              this.$message({
                message: "审批成功",
                type: "success"
              });
              this.list();
              this.dialogConfig1.isShow = false;
            });
          });
        } else if (this.type === "IssueRejection") {
          parmass.approvalSign = "reject";
          flowObj.taskId = "task4";
          flowObj.idea = "0";
          parmas.stauts = 35;
          parmas.id = this.fid;
          const nextAssigneeList = await handleGetNextUsers(flowObj);
          parmas = { ...parmas, ...flowObj, nextAssigneeList };
          trainingRecordAdd(parmass).then(res => {
            trainingMonthlyUpdate(parmas).then(data => {
              this.$message({
                message: "驳回成功",
                type: "success"
              });
              this.list();
              this.dialogConfig1.isShow = false;
            });
          });
        }
      }
    },
    // 下发通知弹窗
    Distribution(id) {
      this.titleConfig1 = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "通知信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "参培单位",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        }
      ];
      this.attachNameshow = false;
      this.formConfig3 = {
        formData: [
          {
            type: "input",
            label: "通知单名称",
            prop: "noticeName",
            isDisabled: false,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "select",
            label: "联系人",
            prop: "contact",
            name: "contactName",
            isDisabled: false,
            class: "half",
            lableWidth: "140px",
            option: [

            ]
          },
          {
            type: "input",
            label: "培训地点",
            prop: "trainingAddress",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系电话",
            maxlength: "11",
            prop: "contactWay",
            isDisabled: false,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训费用",
            prop: "trainingCost",
            isDisabled: false,
            class: "sjgy",
            lableWidth: "140px"
          },
          {
            type: "textarea",
            label: "有关要求",
            isDisabled: false,
            prop: "requirements",
            class: "sjgy",
            lableWidth: "140px"
          },
          {
            type: "upload",
            label: "附件",
            prop: "ztqks",
            action: "#",
            limit: 1,
            lableWidth: "140px"
          }
        ],
        rules: {
          noticeName: [
            { required: true, message: "请输入通知单名称", trigger: "change" }
          ],
          contact: [{ required: true, message: "请选择联系人", trigger: "change" }],
          contactWay: [{ required: true, message: "请输入联系电话", trigger: "change" }],
          requirements: [{ required: true, message: "请输入有关要求", trigger: "change" }]
        }
      };
      this.dialogConfig1.btnList = [
        {
          name: "下发",
          type: "primary",
          id: "Issued",
          size: "mini"
        },
        {
          name: "保存",
          id: "IssuingAndSaving",
          size: "mini"
        },
        {
          name: "取消",
          id: "IssueCancel",
          size: "mini"
        }
      ];
      this.GetByOrganization();
      trainingMonthlyDetail({ id: id.id }).then(res => {
        this.$set(this.$refs.formComponent2.form, "organisedUnitName", res.organisedUnitName);
        this.$set(this.$refs.formComponent3.form, "noticeName", `${res.trainingProjectName}培训通知`);
        this.$set(this.$refs.formComponent2.form, "trainingProjectName", res.trainingProjectName);
        this.$set(this.$refs.formComponent2.form, "trainingTarget", res.trainingTarget);
        this.$set(this.$refs.formComponent3.form, "trainingAddress", res.trainingAddress);
        this.$set(this.$refs.formComponent2.form, "trainStartTime", res.planStartTime);
        this.$set(this.$refs.formComponent2.form, "trainEndTime", res.planEndTime);
        this.checkIssueConfig(res.orgDetailVos);
      });
      this.fid = id.id;
      this.type = "xftz";
      this.dialogConfig1.isShow = true;
      this.formConfig2.formData[1].isDisabled = false;
      this.$nextTick(() => {
        this.$refs.formComponent5.form = this.FilledBy;
      });
    },
    // 动态加载参演单位
    checkIssueConfig(list) {
      if (list.length > 0) {
        list.forEach((item, i) => {
          this.formConfig4[`formConfig${i + 4}`] = {
            formData: [
              {
                type: "input",
                label: `参培单位${i + 1}`,
                prop: "unit",
                class: "half",
                lableWidth: "150px",
                isDisabled: true
              },
              {
                type: "select",
                label: "接收人",
                prop: "receiverId",
                name: "receiver",
                class: "half",
                isDisabled: false,
                lableWidth: "150px",
                option: []
              }
            ],
            rules: {
              receiverId: [
                { required: true, message: "请选择接收人", trigger: "bur" }
              ]
            }
          };
          this.cydwList.push({
            ref: `formComponent${i + 4}`,
            formConfig: this.formConfig4[`formConfig${i + 4}`]
          });
          this.$nextTick(() => {
            this.$set(this.$refs[`formComponent${i + 4}`][0].form, "unit", list[i].orgName || "");
            this.$set(this.$refs[`formComponent${i + 4}`][0].form, "unitId", list[i].id || "");
            if (this.type === "Submission") {
              this.formConfig4[`formConfig${i + 4}`].formData[1].isDisabled = true;
              this.$set(this.$refs[`formComponent${i + 4}`][0].form, "receiverId", list[i].receiverId || "");
              this.$set(this.$refs[`formComponent${i + 4}`][0].form, "receiver", list[i].receiver || "");
            } else if (this.type === "IssuedForEditing" || this.type === "xftz") {
              this.formConfig4[`formConfig${i + 4}`].formData[1].isDisabled = false;
              this.$set(this.$refs[`formComponent${i + 4}`][0].form, "receiverId", list[i].receiverId || "");
              this.$set(this.$refs[`formComponent${i + 4}`][0].form, "receiver", list[i].receiver || "");
            }
          });
          GetByOrganization({ orgId: item.id }).then(res => {
            this.formConfig4[`formConfig${i + 4}`].formData.forEach(i => {
              if (i.label === "接收人") {
                const option = res.map((item) => {
                  const phone = item.phone === null ? "" : `(${item.phone})`;
                  return {
                    label: `${item.realName}${phone}`,
                    value: item.userId
                  };
                });
                i.option = option;

              }
            });
          });
        });
      }
    },
    // 下发
    Issued() {
      this.type = "Issued";
      this.submit();
    },
    // 下发保存
    IssuingAndSaving() {
      this.type = "IssuingAndSaving";
      this.submit();
    },
    // 下发取消
    IssueCancel() {
      this.close1();
    },
    // 下发通知审批
    NoticeForApproval(id) {
      this.type = "Submission";
      this.attachNameshow = true;
      this.titleConfig1 = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "通知信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "参培单位",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        },
        {
          title: "审批信息",
          name: "5",
          slot: "slot5"
        }
      ];
      this.formConfig3 = {
        formData: [
          {
            type: "input",
            label: "通知单名称",
            prop: "noticeName",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系人",
            prop: "contact",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训地点",
            prop: "trainingAddress",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系电话",
            prop: "contactWay",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训费用",
            prop: "trainingCost",
            isDisabled: true,
            class: "sjgy",
            lableWidth: "140px"
          },
          {
            type: "textarea",
            label: "有关要求",
            isDisabled: true,
            prop: "requirements",
            class: "sjgy",
            lableWidth: "140px"
          }
        ]
      };
      this.formConfig7 = {
        formData: [{
          type: "input",
          label: "审批意见",
          isDisabled: false,
          prop: "approvalOpinion",
          class: "sjgy",
          lableWidth: "140px"
        },
        {
          type: "input",
          label: "审批人",
          isDisabled: true,
          prop: "approvalUser",
          class: "third",
          lableWidth: "140px"
        },
        {
          type: "input",
          label: "单位及部门",
          isDisabled: true,
          class: "third",
          prop: "approvalDept",
          lableWidth: "140px"
        },
        {
          type: "input",
          label: "审批时间",
          isDisabled: true,
          class: "third",
          prop: "approvalTime",
          lableWidth: "140px"
        }]
      };
      this.formConfig2.formData[1].isDisabled = true;
      this.EditApprovalSubmission(id);
    },
    // 下发通知编辑
    IssuedForEditing(id) {
      this.type = "IssuedForEditing";
      this.attachNameshow = false;
      this.titleConfig1 = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "通知信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "参培单位",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        }
      ];
      this.formConfig3 = {
        formData: [
          {
            type: "input",
            label: "通知单名称",
            prop: "noticeName",
            isDisabled: false,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "select",
            label: "联系人",
            prop: "contact",
            name: "contactName",
            isDisabled: false,
            class: "half",
            lableWidth: "140px",
            option: [

            ]
          },
          {
            type: "input",
            label: "培训地点",
            prop: "trainingAddress",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系电话",
            prop: "contactWay",
            maxlength: "11",
            isDisabled: false,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训费用",
            prop: "trainingCost",
            isDisabled: false,
            class: "sjgy",
            lableWidth: "140px"
          },
          {
            type: "textarea",
            label: "有关要求",
            isDisabled: false,
            prop: "requirements",
            class: "sjgy",
            lableWidth: "140px"
          },
          {
            type: "upload",
            label: "附件",
            prop: "ztqks",
            action: "#",
            limit: 1,
            lableWidth: "140px"
          }
        ],
        rules: {
          noticeName: [
            { required: true, message: "请输入通知单名称", trigger: "change" }
          ],
          contact: [{ required: true, message: "请选择联系人", trigger: "change" }],
          contactWay: [{ required: true, message: "请输入联系电话", trigger: "change" }],
          requirements: [{ required: true, message: "请输入有关要求", trigger: "change" }]
        }
      };
      this.formConfig2.formData[1].isDisabled = false;
      this.GetByOrganization();
      this.EditApprovalSubmission(id);
    },
    // 下发通知编辑和审批
    EditApprovalSubmission(id) {
      this.fid = id.id;
      this.dialogConfig1.isShow = true;
      trainingMonthlyDetail({ id: id.id }).then(res => {
        this.$set(this.$refs.formComponent2.form, "organisedUnitName", res.organisedUnitName);
        this.$set(this.$refs.formComponent2.form, "trainingProjectName", res.trainingProjectName);
        this.$set(this.$refs.formComponent2.form, "trainingTarget", res.trainingTarget);
        this.$set(this.$refs.formComponent2.form, "trainStartTime", res.trainStartTime);
        this.$set(this.$refs.formComponent2.form, "trainEndTime", res.trainEndTime);
        this.$set(this.$refs.formComponent3.form, "trainingAddress", res.trainingAddress);
        this.$refs.formComponent5.form = res;
        this.$set(this.$refs.formComponent5.form, "creatorUnit", res.creatorUnit);
        this.checkIssueConfig(res.orgDetailVos);
      });
      trainingNoticeDetail({ id: id.id }).then(res => {
        this.IssuedId = res.id;
        this.$refs.formComponent3.form = res;
        if (this.type === "Submission") {
          this.attachInfo = JSON.parse(res.attachInfo);
        } else if (this.type === "IssuedForEditing") {
          const list = JSON.parse(res.attachInfo);
          const newList = [];
          list.forEach(item => {
            newList.push({
              name: item.attachName,
              attachId: item.attachId
            });
          });
          console.log(newList);
          this.$set(this.$refs.formComponent3, "fileList", newList);
        }
        this.$set(this.$refs.formComponent3.form, "contact", res.contact);
        this.attachInfo = JSON.parse(res.attachInfo);
      });
      if (this.type === "Submission") {
        this.$nextTick(() => {
          this.$refs.formComponent7.form = this.FilledBy;
        });
        this.dialogConfig1.btnList = [
          {
            name: "同意",
            id: "IssuedForApproval", // 事件名
            type: "primary",
            size: "small"
          },
          {
            name: "驳回",
            id: "IssueRejection",
            size: "small"
          },
          {
            name: "取消",
            id: "IssueCancel",
            size: "small"
          }
        ];
      } else if (this.type === "IssuedForEditing") {
        this.dialogConfig1.btnList = [
          {
            name: "下发",
            type: "primary",
            id: "Issued",
            size: "mini"
          },
          {
            name: "保存",
            id: "IssuingAndSaving",
            size: "mini"
          },
          {
            name: "取消",
            id: "IssueCancel",
            size: "mini"
          }
        ];
      }
    },
    // 下发同意
    IssuedForApproval() {
      this.type = "IssuedForApproval";
      this.submit();
    },
    // 下发驳回
    IssueRejection() {
      this.type = "IssueRejection";
      this.submit();
    },
    // 选择月度计划必填主办单位
    handleNodeClick(data, node, item) {
      if (item.label === "主办单位") {
        this.$set(this.$refs.formComponent.form, "organisedUnitName", data.orgName);
        this.$set(this.$refs.formComponent.form, "organisedUnitId", data.id);

      }
    },
    // 获取下拉框数据
    getInputVal() {
      this.formConfig.formData.forEach((item) => {
        if (item.label === "关联年计划") {
          trainingYearlyList().then(res => {
            const option = res.map((item) => {
              return {
                label: item.trainingProjectName,
                value: item.id
              };
            });
            item.option = option;
          });
        }
      });
      this.formData.forEach((item) => {
        if (item.label === "关联年计划") {
          trainingYearlyList().then(res => {
            const option = res.map((item) => {
              return {
                label: item.trainingProjectName,
                value: item.id
              };
            });
            item.options = option;
          });
        }
      });
    },
    // 列表表格按钮事件
    actionHandle(item, scope) {
      // 默认进入编辑
      if (scope.row.stauts === 0 || scope.row.stauts === 6 || scope.row.stauts === 1) {
        this.HanEdit(scope.row);
      } else if (scope.row.stauts === 3) {
        this.ApprovalForm(scope.row);
      } else if (item === "下发通知") {
        this.Distribution(scope.row);
      } else if (item === "驳回") {
        this.RejectFrom(scope.row);
        // 下发通知审批
      } else if (item === "通知审批") {
        this.NoticeForApproval(scope.row);
        // 下发通知编辑
      } else if (scope.row.stauts === 34 || scope.row.stauts === 35) {
        this.IssuedForEditing(scope.row);
      } else if (item === "删除") {
        this.detailForm(scope.row);
        // 人员反馈
      } else if (scope.row.stauts === 4) {
        this.PersonnelFeedback(scope.row);
        // 人员反馈审批
      } else if (scope.row.stauts === 36) {
        this.PersonnelReportingforApproval(scope.row);
      } else if (scope.row.stauts === 37 || scope.row.stauts === 39) {
        this.PersonnelReportingandediting(scope.row);
      } else if (item === "上传结果") {
        this.Shchan(scope.row, 1);
      } else if (item === "查看结果") {
        this.TrainingDetails(scope.row, 1);
      } else if (item === "签到表") {
        this.Shchan(scope.row, 2);
      } else if (item === "成绩单") {
        this.Shchan(scope.row, 3);
      } else if (item === "查看签到表") {
        this.TrainingDetails(scope.row, 2);
      } else if (item === "查看成绩单") {
        this.TrainingDetails(scope.row, 3);

      }
    },
    // 列表
    async list() {
      const parmas = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        projectType: 3,
        roleCode: JSON.parse(sessionStorage.getItem("role")).roleCode,
        flowKey: "plan_001"
      };
      const res = await trainingMonthlyListPage(parmas);
      this.table.tableData = res.data;
      this.table.paginationAtrrs.total = res.total;
    },
    // 新增
    TemporaryplanAdd() {
      this.type = "TemporaryplanAdd";
      this.distinguish = "";
      this.titleConfig = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "培训明细信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "填报信息",
          name: "3",
          slot: "slot3"
        }
      ];
      this.dialogConfig.btnList = [
        {
          name: "提交",
          id: "submitForms", // 事件名
          type: "primary",
          size: "small"
        },
        {
          name: "保存",
          id: "BSubmit",
          size: "small"
        },
        {
          name: "取消",
          id: "Qxiao",
          size: "small"
        }
      ];
      this.formConfig.formData = [{
        type: "selectTree",
        label: "主办单位",
        prop: "organisedUnitName",
        name: "organisedUnitId",
        keyWord: "keyWord",
        treeRef: "treeRef",
        commonClick: true,
        isSplice: true,
        chooseUnit: true,
        title: "主办单位选择",
        choose: false,
        ref: "tree_select1",
        class: "half",
        multiple: false,
        lableWidth: "130px",
        option: [],
        treeData: {
          data: [],
          default: ["1"],
          checked: [],
          props: {
            children: "children",
            label: "orgName",
            value: "id"
          }
        }
      },
      {
        type: "input",
        label: "培训项目",
        isDisabled: false,
        prop: "trainingProjectName",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "inputNumber",
        label: "培训总期次",
        isDisabled: false,
        prop: "trainingPeriod",
        min: 1,
        max: 2,
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "select",
        label: "计划类型",
        isDisabled: false,
        prop: "projectType",
        name: "projectTypeName",
        class: "half",
        lableWidth: "130px",
        option: [{ label: "临时计划", value: 3 }, { label: "月度计划", value: 2 }]
      },
      {
        type: "input",
        label: "培训地点",
        isDisabled: false,
        prop: "trainingAddress",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "培训对象",
        isDisabled: false,
        prop: "trainingTarget",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "select",
        label: "关联年计划",
        isDisabled: false,
        prop: "associatedTrainingId",
        class: "half",
        lableWidth: "130px",
        option: []
      },
      {
        type: "textarea",
        label: "主要培训内容",
        isDisabled: false,
        prop: "trainingContent",
        class: "sjgy",
        lableWidth: "130px"
      }];

      this.formConfig.rules = {
        organisedUnitName: [
          { required: true, message: "请选择主办单位", trigger: "bur" }
        ],
        trainingProjectName: [{ required: true, message: "请输入培训项目", trigger: "bur" }],
        trainingPeriod: [{ required: true, message: "请输入培训总期次", trigger: "bur" }],
        projectType: [
          { required: true, message: "请选择计划类型", trigger: "bur" }
        ],
        trainingTarget: [{ required: true, message: "请输入培训对象", trigger: "bur" }],
        trainingContent: [{ required: true, message: "请输入培训内容", trigger: "bur" }]
      };
      // this.tables.tableData = [
      // ];
      this.tableColumn = true;
      this.getUnitTree();
      this.getInputVal();
      this.dialogConfig.isShow = true;
      this.$nextTick(() => {
        this.$refs.formComponent1.form = this.FilledBy;
        this.$set(this.$refs.formComponent.form, "organisedUnitName", JSON.parse(sessionStorage.getItem("org")).orgName);
        this.$set(this.$refs.formComponent.form, "organisedUnitId", JSON.parse(sessionStorage.getItem("org")).orgId);
      });
    },
    // 提交
    submitForms() {
      if (this.type === "TemporaryplanAdd") {
        this.submitForm(); // 新增
      } else {
        this.type = "bjtj";
        this.submitForm(); // 编辑
      }
    },
    // 保存提交审批驳回
    async submitForm() {
      const flowObj = {
        bizKey: this.fid,
        flowKey: "plan_001",
        taskId: "task1",
        idea: "1",
        ideaMsg: ""
      };
      let flag = null;
      let emptFlag = null;
      if (this.distinguish === "bjbc") {
        this.$refs.formComponentbj.isValidate();
        flag = this.$refs.formComponentbj.flag;
        emptFlag = true;
        const newTableData = this.tablesbj.tableData;
        newTableData.forEach((item, index) => {
          if (item.planStartTime === "" || item.planStartTime === null || item.planStartTime === undefined) {
            this.$message({
              message: `请输入计划开始时间`,
              type: "warning"
            });
            emptFlag = false;
          } else if (item.planEndTime === "" || item.planEndTime === null || item.planEndTime === undefined) {
            this.$message({
              message: `请输入计划完成时间`,
              type: "warning"
            });
            emptFlag = false;
          }
        });
      } else {
        this.$refs.formComponent.isValidate();
        flag = this.$refs.formComponent.flag;
        emptFlag = true;
        const newTableData = this.tables.tableData;
        // newTableData.map((item, index) => {
        //   this.monthlyBatchDtos.push({
        //     planStartTime: item.planStartTime,
        //     planEndTime: item.planEndTime,
        //     planTrainingCount: item.planTrainingCount,
        //     trainingPeriod: item.trainingPeriod,
        //     trainingTargetUnitId: index ? this.trainingTargetUnitId1.join(",") : this.trainingTargetUnitId0.join(","),
        //     trainingTargetUnit: index ? this.trainingTargetUnit1.join(",") : this.trainingTargetUnit0.join(",")
        //   });
        // });
        newTableData.forEach((item, index) => {
          if (item.planStartTime === "" || item.planStartTime === null || item.planStartTime === undefined) {
            this.$message({
              message: `请输入计划开始时间`,
              type: "warning"
            });
            emptFlag = false;
          } else if (item.planEndTime === "" || item.planEndTime === null || item.planEndTime === undefined) {
            this.$message({
              message: `请输入计划完成时间`,
              type: "warning"
            });
            emptFlag = false;
          }
        });
      }
      if (flag && emptFlag) {
        console.log(this.newTableData, "newTableDatanewTableDatanewTableData");
        let pamas = {};
        if (this.distinguish === "bjbc") {
          console.log("bjbc");
          pamas = {
            trainingProjectName: this.$refs.formComponentbj.form.trainingProjectName,
            projectType: this.$refs.formComponentbj.form.projectType === "临时计划" ? 3 : this.$refs.formComponentbj.form.projectType === "月度计划" ? 2 : this.$refs.formComponentbj.form.projectType,
            trainingTarget: this.$refs.formComponentbj.form.trainingTarget,
            trainingContent: this.$refs.formComponentbj.form.trainingContent,
            trainingAddress: this.$refs.formComponentbj.form.trainingAddress,
            monthlyBatchDtos: this.tables.tableData,
            associatedTrainingId: this.$refs.formComponentbj.form.associatedTrainingId,
            organisedUnitName: this.$refs.formComponentbj.form.organisedUnitName,
            organisedUnitId: this.$refs.formComponentbj.form.organisedUnitId,
            planStartTime: this.tablesbj.tableData[0].planStartTime ? this.tablesbj.tableData[0].planStartTime : "",
            planEndTime: this.tablesbj.tableData[0].planEndTime ? this.tablesbj.tableData[0].planEndTime : "",
            planTrainingCount: this.tablesbj.tableData[0].planTrainingCount ? this.tablesbj.tableData[0].planTrainingCount : "",
            trainingPeriod: this.tablesbj.tableData[0].trainingPeriod ? this.tablesbj.tableData[0].trainingPeriod : "",
            trainingTargetUnitId: this.$refs.formComponentcybj.form.trainingTargetUnitId.join(","),
            trainingTargetUnit: this.$refs.formComponentcybj.form.trainingTargetUnit.join(",")
          };
        } else if (this.type === "TemporaryplanAdd" || this.type === 2) {
          pamas = {
            trainingProjectName: this.$refs.formComponent.form.trainingProjectName,
            trainingPeriod: this.$refs.formComponent.form.trainingPeriod,
            projectType: this.$refs.formComponent.form.projectType === "临时计划" ? 3 : this.$refs.formComponent.form.projectType === "月度计划" ? 2 : this.$refs.formComponent.form.projectType,
            trainingTarget: this.$refs.formComponent.form.trainingTarget,
            trainingContent: this.$refs.formComponent.form.trainingContent,
            trainingAddress: this.$refs.formComponent.form.trainingAddress,
            monthlyBatchDtos: this.tables.tableData,
            associatedTrainingId: this.$refs.formComponent.form.associatedTrainingId,
            organisedUnitName: this.$refs.formComponent.form.organisedUnitName,
            organisedUnitId: this.$refs.formComponent.form.organisedUnitId,
            creator: JSON.parse(sessionStorage.getItem("account")).realName,
            creatorId: JSON.parse(sessionStorage.getItem("account")).id,
            // deptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
            creatorUnit: sessionStorage.getItem("dwbmName")
          };
        }
        const parmass = {
          approvalUserId: JSON.parse(sessionStorage.getItem("account")).id,
          approvalUser: JSON.parse(sessionStorage.getItem("account")).realName,
          approvalDeptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
          approvalDept: sessionStorage.getItem("dwbmName"),
          approvalType: "02",
          refId: this.fid
        };
        // 提交
        if (this.type === "TemporaryplanAdd") {
          pamas.id = this.fid;
          pamas.stauts = 3;
          const nextAssigneeList = await handleGetNextUsers(flowObj);
          pamas = { ...pamas, ...flowObj, nextAssigneeList };
          trainingMonthlyInsert(pamas).then(res => {

            if (res) {
              this.$message({
                message: "提交成功",
                type: "success"
              });
              this.list();
              this.dialogConfig.isShow = false;
              // this.gzlSubmit(res, pamas);
            }
          });
          // 保存
        } else if (this.type === 2) {
          console.log(pamas, "pamaspamas");

          pamas.id = this.fid;
          pamas.stauts = 1;
          trainingMonthlyInsert(pamas).then(data => {
            this.$message({
              message: "保存成功",
              type: "success"
            });
            this.list();
            this.dialogConfig.isShow = false;
          });
          // 编辑提交
        } else if (this.type === "bjtj") {
          pamas.id = this.fid;
          pamas.stauts = 3;
          const nextAssigneeList = await handleGetNextUsers(flowObj);
          pamas = { ...pamas, ...flowObj, nextAssigneeList };
          trainingMonthlyUpdate(pamas).then(data => {

            if (data) {
              // this.gzlSubmit(this.fid, pamas);
              this.$message({
                message: "保存成功",
                type: "success"
              });
              this.list();
              this.dialogConfigbj.isShow = false;
            }
          });
          // 审批
        } else if (this.type === 3) {
          parmass.approvalOpinion = this.$refs.formComponents.form.approvalOpinion;
          parmass.approvalSign = "pass";
          flowObj.taskId = "task2";
          flowObj.idea = "1";
          pamas.stauts = 2;
          pamas.id = this.fid;
          const nextAssigneeList = await handleGetNextUsers(flowObj);
          pamas = { ...pamas, ...flowObj, nextAssigneeList };
          // this.gzlAudit(3, parmass);
          trainingRecordAdd(parmass).then(res => {
            trainingMonthlyUpdate(pamas).then(data => {
              this.$message({
                message: "审批成功",
                type: "success"
              });
              this.list();
              this.dialogConfig.isShow = false;
            });
          });
          // 驳回
        } else if (this.type === 4) {
          // this.gzlAudit(4, parmass);
          parmass.approvalSign = "reject";
          flowObj.taskId = "task2";
          flowObj.idea = "1";
          pamas.stauts = 6;
          pamas.id = this.fid;
          const nextAssigneeList = await handleGetNextUsers(flowObj);
          pamas = { ...pamas, ...flowObj, nextAssigneeList };
          trainingRecordAdd(parmass).then(res => {
            trainingMonthlyUpdate(pamas).then(data => {
              this.$message({
                message: "驳回成功",
                type: "success"
              });
              this.list();
              this.dialogConfig.isShow = false;
            });
          });
          // 编辑保存
        } else if (this.type === "bjbc") {
          pamas.id = this.fid;
          pamas.stauts = 1;
          trainingMonthlyUpdate(pamas).then(data => {
            this.$message({
              message: "保存成功",
              type: "success"
            });
            this.list();
            this.dialogConfigbj.isShow = false;
          });
          // 编辑保存
        }
      }
      // this.$refs.formComponent.form = this.$refs.formComponent.$options.data().form;
    },
    // 保存
    BSubmit() {
      if (this.type === "TemporaryplanAdd") {
        this.type = 2; // 新增
        this.submitForm();
      } else {
        this.type = "bjbc"; // 编辑
        this.submitForm();
      }
    },
    // 审批
    ApprovalForm(id) {
      this.distinguish = 1;
      this.titleConfig = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "培训明细信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "填报信息",
          name: "3",
          slot: "slot3"
        },
        {
          title: "审批信息",
          name: "4",
          slot: "slot4"
        }
      ];
      this.formConfig.formData = [{
        type: "selectTree",
        label: "主办单位",
        prop: "organisedUnitName",
        name: "organisedUnitId",
        keyWord: "keyWord",
        treeRef: "treeRef",
        title: "主办单位选择",
        choose: false,
        ref: "tree_select1",
        class: "half",
        multiple: false,
        isDisabled: true,
        lableWidth: "130px",
        option: [],
        treeData: {
          data: [],
          default: ["1"],
          checked: [],
          props: {
            children: "children",
            label: "orgName",
            value: "id"
          }
        }
      },
      {
        type: "input",
        label: "培训项目",
        isDisabled: true,
        prop: "trainingProjectName",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "培训总期次",
        isDisabled: true,
        prop: "trainingPeriod",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "计划类型",
        isDisabled: true,
        prop: "projectType",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "培训地点",
        isDisabled: true,
        prop: "trainingAddress",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "培训对象",
        isDisabled: true,
        prop: "trainingTarget",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "关联年计划",
        isDisabled: true,
        prop: "associatedTrainingName",
        class: "half",
        lableWidth: "130px",
        option: []
      },
      {
        type: "textarea",
        label: "主要培训内容",
        isDisabled: true,
        prop: "trainingContent",
        class: "sjgy",
        lableWidth: "130px"
      }];
      this.$nextTick(() => {
        this.$refs.formComponents.form = this.FilledBy;
      });
      this.tableColumn = false;
      this.ApproveEdit(id);
      this.dialogConfig.isShow = true;
    },
    // 编辑
    HanEdit(id) {
      this.distinguish = "bjbc";
      this.titleConfigbj = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "培训明细信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "填报信息",
          name: "3",
          slot: "slot3"
        }
      ];
      this.formConfigbj.formData = [{
        type: "selectTree",
        label: "主办单位",
        prop: "organisedUnitName",
        name: "organisedUnitId",
        keyWord: "keyWord3",
        treeRef: "treeRef3",
        title: "主办单位选择",
        choose: false,
        ref: "tree_select3",
        class: "half",
        multiple: false,
        isDisabled: true,
        lableWidth: "130px",
        option: [],
        treeData: {
          data: [],
          default: ["1"],
          checked: [],
          props: {
            children: "children",
            label: "orgName",
            value: "id"
          }
        }
      },
      {
        type: "input",
        label: "培训项目",
        isDisabled: true,
        prop: "trainingProjectName",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "培训总期次",
        isDisabled: true,
        prop: "trainingPeriod",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "计划类型",
        isDisabled: true,
        prop: "projectType",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "培训地点",
        isDisabled: true,
        prop: "trainingAddress",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "培训对象",
        isDisabled: true,
        prop: "trainingTarget",
        class: "half",
        lableWidth: "130px"
      },
      {
        type: "input",
        label: "关联年计划",
        isDisabled: true,
        prop: "associatedTrainingName",
        class: "half",
        lableWidth: "130px",
        option: []
      },
      {
        type: "textarea",
        label: "主要培训内容",
        isDisabled: true,
        prop: "trainingContent",
        class: "sjgy",
        lableWidth: "130px"
      }];
      this.formConfigbj.rules = {};
      this.tablesbj.tableData = [
        { trainingPeriod: "", planStartTime: "", planEndTime: "", trainingTargetUnit: "", planTrainingCount: "" }
      ];
      // this.tableColumn = true;
      this.getUnitTree();
      this.ApproveEdit(id);
      this.dialogConfigbj.isShow = true;
    },
    // 审批编辑处理
    ApproveEdit(id) {
      this.fid = id.id;
      this.getInputVal();
      trainingMonthlyDetail({ id: id.id }).then(res => {
        if (this.distinguish === 1) {
          const arr = [];
          arr.push(res);
          this.tables.tableData = arr;
          this.$refs.formComponent.form = res;
          this.$refs.formComponent1.form = res;
          if (res.projectType === 3) {
            this.$set(this.$refs.formComponent.form, "projectType", "临时计划");
          } else if (res.projectType === 2) {
            this.$set(this.$refs.formComponent.form, "projectType", "月度计划");
          }
          this.$set(this.$refs.formComponent.form, "trainingPeriod", res.trainingPeriod);
          this.$set(this.$refs.formComponent1.form, "creatorUnit", res.creatorUnit);
          this.dialogConfig.btnList = [
            {
              name: "同意",
              id: "AgreeFrom", // 事件名
              type: "primary",
              size: "small"
            },
            {
              name: "驳回",
              id: "RejectFrom",
              size: "small"
            },
            {
              name: "取消",
              id: "Qxiao",
              size: "small"
            }
          ];
        } else if (this.distinguish === "bjbc") {
          const arr = [];
          arr.push(res);
          this.tablesbj.tableData = arr;
          this.$refs.formComponentbj.form = res;
          this.$refs.formComponent1.form = res;
          this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnit", res.trainingTargetUnit.split(","));
          this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnitId", res.trainingTargetUnitId.split(","));
          if (res.projectType === 3) {
            this.$set(this.$refs.formComponentbj.form, "projectType", "临时计划");
          } else if (res.projectType === 2) {
            this.$set(this.$refs.formComponentbj.form, "projectType", "月度计划");
          }
          this.$set(this.$refs.formComponentbj.form, "trainingPeriod", res.trainingPeriod);
          this.$set(this.$refs.formComponent1.form, "creatorUnit", res.creatorUnit);
          this.dialogConfigbj.btnList = [
            {
              name: "提交",
              id: "submitForms", // 事件名
              type: "primary",
              size: "small"
            },
            {
              name: "保存",
              id: "BSubmit",
              size: "small"
            },
            {
              name: "取消",
              id: "Qxiaobj",
              size: "small"
            }
          ];
        }
      });

    },
    // 同意
    AgreeFrom() {
      this.type = 3;
      this.submitForm();
    },
    // 驳回
    RejectFrom() {
      this.type = 4;
      this.submitForm();
    },
    // 取消
    Qxiao() {
      this.$refs.formComponent.form = this.$refs.formComponent.$options.data().form;
      this.trainingTargetUnit0 = [];
      this.trainingTargetUnitId0 = [];
      this.trainingTargetUnit1 = [];
      this.trainingTargetUnitId1 = [];
      this.$nextTick(() => {
        this.$refs.formComponent.$refs.formInlines.clearValidate();
      });
      this.dialogConfig.isShow = false;
    },
    Qxiaobj() {
      this.tablesbj.tableData = [];
      // this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnit", "");
      // this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnitId", "");
      this.dialogConfigbj.isShow = false;
    },
    // 弹窗关闭图标
    close() {
      this.$refs.formComponent.form = this.$refs.formComponent.$options.data().form;
      this.trainingTargetUnit0 = [];
      this.trainingTargetUnitId0 = [];
      this.trainingTargetUnit1 = [];
      this.trainingTargetUnitId1 = [];
      this.$nextTick(() => {
        this.$refs.formComponent.$refs.formInlines.clearValidate();
      });
      this.dialogConfig.isShow = false;
    },
    closebj() {
      this.tablesbj.tableData = [];
      // this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnit", "");
      // this.$set(this.$refs.formComponentcybj.form, "trainingTargetUnitId", "");
      this.dialogConfigbj.isShow = false;
    },
    // 人员上报弹窗按钮事件
    handleBtn2(item) {
      this[item.id]();
    },
    // 人员上报弹窗
    close2() {
      this.personnelConfig.table.tableData = [];
      this.dialogConfig2.isShow = false;
    },
    close3() { this.ChooseConfig.isShow = false; },
    // 人员上报弹窗取消
    PersonnelCancellation() { this.close2(); },
    // 选择人员
    getResourcesData() {
      this.ChooseConfig.isShow = true;
      this.ChooseConfig.unit = "名人员";
      this.getPlayerList();
      getOrgDepartmentList({ orgId: JSON.parse(sessionStorage.getItem("org")).orgId }).then(data => {
        // this.formConfigcy.formData[0].treeData.data = data;
        // this.formConfigcybj.formData[0].treeData.data = data;
        this.PersonnelFormConfig.formData[3].treeData.data = data;
      });
    },
    checkSelect(val, selection) {
      this.$refs.dialogChoose.selection = val;
    },
    // 人员选择弹窗分页getPlayerList
    handleChooseChange(select, item, val) {
      const data = {
        pageNum: val["current-page"],
        pageSize: val["page-size"]
      };
      this.chooseQuery(select, item, data);
    },
    // 弹窗选人组件筛选
    chooseQuery(select, val, item) {
      this.getPlayerList(select, val, item);
    },
    // 获取队员列表
    getPlayerList(select, val, item) {
      this.PersonnelFormConfig.formData.forEach((s) => {
        if (s.dic === "memberMajor") {
          dicList({ code: "yz_ry_ryzy" }).then(res => {
            const option = res.map((val) => {
              return {
                label: val.dicName,
                value: val.dicName
              };
            });
            s.option = option;
          });
        } else if (s.dic === "memberType") {
          dicList({ code: "yz_ry_ryxz" }).then(res => {
            const option = res.map((val) => {
              return {
                label: val.dicName,
                value: val.dicName
              };
            });
            s.option = option;
          });
        }
      });
      console.log(item, "parmas");
      let parmas = {
        pageNum: this.PersonnelTableConfig.paginationAtrrs["current-page"],
        pageSize: 100,
        accessUnitId: JSON.parse(sessionStorage.getItem("org")).orgId
      };
      if (val && !item) {
        parmas = {
          pageNum: this.PersonnelTableConfig.paginationAtrrs["current-page"],
          pageSize: 100,
          accessUnitId: JSON.parse(sessionStorage.getItem("org")).orgId,
          ...val
        };
      } else if (item) {
        parmas = item;
      }
      parmas.occupation = "";
      getMembers(parmas).then(data => {
        this.PersonnelTableConfig.tableData = data;
        this.PersonnelTableConfig.paginationAtrrs.total = data.length;
      });
    },
    // 人员选择点击确认
    teamAdd(item, selecetion) {
      this.personnelConfig.table.tableData = selecetion;
      this.ChooseConfig.isShow = false;
    },
    // 人员反馈上报
    PersonnelFeedback(id) {
      this.dialogConfig2.isShow = true;
      this.fid = id.id;
      this.attachNameshow = true;
      this.titleConfig2 = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "通知信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "参培人员",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        }
      ];
      this.dialogConfig2.btnList = [
        {
          name: "提交",
          type: "primary",
          id: "PersonnelSubmission",
          size: "mini"
        },
        {
          name: "保存",
          id: "PersonnelSaving",
          size: "mini"
        },
        {
          name: "取消",
          id: "PersonnelCancellation",
          size: "mini"
        }
      ];
      this.formConfig3 = {
        formData: [
          {
            type: "input",
            label: "通知单名称",
            prop: "noticeName",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系人",
            prop: "contact",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训地点",
            prop: "trainingAddress",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系电话",
            prop: "contactWay",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训费用",
            prop: "trainingCost",
            isDisabled: true,
            class: "sjgy",
            lableWidth: "140px"
          },
          {
            type: "textarea",
            label: "有关要求",
            isDisabled: true,
            prop: "requirements",
            class: "sjgy",
            lableWidth: "140px"
          }
        ]
      };
      this.$nextTick(() => {
        this.$refs.formComponent5.form = this.FilledBy;
      });
      this.formConfig2.formData[1].isDisabled = true;
      trainingMonthlyDetail({ id: id.id }).then(res => {
        this.$set(this.$refs.formComponent2.form, "organisedUnitName", res.organisedUnitName);
        this.$set(this.$refs.formComponent2.form, "trainingProjectName", res.trainingProjectName);
        this.$set(this.$refs.formComponent2.form, "organisedUnitName", res.organisedUnitName);
        this.$set(this.$refs.formComponent2.form, "trainingTarget", res.trainingTarget);
        this.$set(this.$refs.formComponent2.form, "trainStartTime", res.trainStartTime);
        this.$set(this.$refs.formComponent2.form, "trainEndTime", res.trainEndTime);
        trainingNoticeDetail({ id: id.id }).then(res => {
          this.IssuedId = res.id;
          this.$refs.formComponent3.form = res;
          this.$set(this.$refs.formComponent3.form, "trainingAddress", res.trainingAddress);
          this.$set(this.$refs.formComponent3.form, "contact", res.contact);
          this.attachInfo = JSON.parse(res.attachInfo);
        });
      });
    },
    // 人员上报提交同意保存驳回
    GetPersonnelReporting() {
      if (this.personnelConfig.table.tableData.length === 0) {
        this.$message({
          message: "请选择人员",
          type: "warning"
        });
      } else {
        const arr = this.personnelConfig.table.tableData;
        arr.forEach(item => {
          item.associatedTrainingId = this.fid;
        });
        const parmas = arr;
        const parmass = {
          approvalUserId: JSON.parse(sessionStorage.getItem("account")).id,
          approvalUser: JSON.parse(sessionStorage.getItem("account")).realName,
          approvalDeptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
          approvalDept: sessionStorage.getItem("dwbmName"),
          refId: this.fid,
          approvalType: "02"
        };
        if (this.type === "PersonnelSubmission") {
          trainingDrillStaffInsertOrUpdate(parmas).then(res => {
            trainingMonthlyUpdate({
              id: this.fid,
              stauts: 36
            }).then(data => {
              this.$message({
                message: "提交成功",
                type: "success"
              });
              this.list();
              this.dialogConfig2.isShow = false;
            });
          });
        } else if (this.type === "PersonnelSaving") {
          trainingDrillStaffInsertOrUpdate(parmas).then(res => {
            trainingMonthlyUpdate({
              id: this.fid,
              stauts: 37
            }).then(data => {
              this.$message({
                message: "保存成功",
                type: "success"
              });
              this.list();
              this.dialogConfig2.isShow = false;
            });
          });
        } else if (this.type === "PersonnelReportandAgree") {
          parmass.approvalSign = "pass";
          parmass.approvalOpinion = this.$refs.formComponent8.form.approvalOpinion;
          trainingDrillStaffUpdate(parmass).then(res => {
            trainingMonthlyUpdate({
              id: this.fid,
              stauts: 38,
              actualTrainingCount: this.personnelConfig.table.tableData.length
            }).then(data => {
              trainingYearlyUpdate({
                monthlyId: this.fid,
                id: this.fid,
                stauts: 40
              }).then(data => {
                this.$message({
                  message: "审批成功",
                  type: "success"
                });
                this.list();
                this.dialogConfig2.isShow = false;
              });
            });
          });
        } else if (this.type === "PersonnelReportRejection") {
          parmass.approvalSign = "reject";
          trainingDrillStaffUpdate(parmass).then(res => {
            trainingMonthlyUpdate({
              id: this.fid,
              stauts: 39
            }).then(data => {
              this.$message({
                message: "驳回成功",
                type: "success"
              });
              this.list();
              this.dialogConfig2.isShow = false;
            });
          });
        }
      }
    },
    // 人员上报提交
    PersonnelSubmission() {
      this.type = "PersonnelSubmission";
      this.GetPersonnelReporting();
    },
    // 人员上报保存
    PersonnelSaving() {
      this.type = "PersonnelSaving";
      this.GetPersonnelReporting();
    },
    // 人员上报同意
    PersonnelReportandAgree() {
      this.type = "PersonnelReportandAgree";
      this.GetPersonnelReporting();
    },
    // 人员上报驳回
    PersonnelReportRejection() {
      this.type = "PersonnelReportRejection";
      this.GetPersonnelReporting();
    },
    // 人员上报审批编辑处理
    PersonnelApprovalEdit(id) {
      this.dialogConfig2.isShow = true;
      this.attachNameshow = true;
      this.formConfig2.formData[1].isDisabled = true;
      this.fid = id.id;
      this.dialogConfig2.btnList = [
        {
          name: "提交",
          type: "primary",
          id: "PersonnelSubmission",
          size: "mini"
        },
        {
          name: "保存",
          id: "PersonnelSaving",
          size: "mini"
        },
        {
          name: "取消",
          id: "PersonnelCancellation",
          size: "mini"
        }
      ];
      this.formConfig3 = {
        formData: [
          {
            type: "input",
            label: "通知单名称",
            prop: "noticeName",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系人",
            prop: "contact",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训地点",
            prop: "trainingAddress",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "联系电话",
            prop: "contactWay",
            isDisabled: true,
            class: "half",
            lableWidth: "140px"
          },
          {
            type: "input",
            label: "培训费用",
            prop: "trainingCost",
            isDisabled: true,
            class: "sjgy",
            lableWidth: "140px"
          },
          {
            type: "textarea",
            label: "有关要求",
            isDisabled: true,
            prop: "requirements",
            class: "sjgy",
            lableWidth: "140px"
          }
        ]
      };

      trainingMonthlyDetail({ id: id.id }).then(res => {
        this.$set(this.$refs.formComponent2.form, "organisedUnitName", res.organisedUnitName);
        this.$set(this.$refs.formComponent2.form, "trainingProjectName", res.trainingProjectName);
        this.$set(this.$refs.formComponent2.form, "organisedUnitName", res.organisedUnitName);
        this.$set(this.$refs.formComponent2.form, "trainingProjectName", res.trainingProjectName);
        this.$set(this.$refs.formComponent2.form, "trainingTarget", res.trainingTarget);
        this.$refs.formComponent5.form = res;
        this.$set(this.$refs.formComponent5.form, "creatorUnit", res.creatorUnit);
        trainingNoticeDetail({ id: id.id }).then(res => {
          this.IssuedId = res.id;
          this.$refs.formComponent3.form = res;
          this.$set(this.$refs.formComponent3.form, "trainingAddress", res.trainingAddress);
          this.$set(this.$refs.formComponent3.form, "contact", res.contact);
          this.attachInfo = JSON.parse(res.attachInfo);
        });
      });
      if (this.type === "PersonnelReportingandediting") {
        this.dialogConfig2.btnList = [
          {
            name: "提交",
            type: "primary",
            id: "PersonnelSubmission",
            size: "mini"
          },
          {
            name: "保存",
            id: "PersonnelSaving",
            size: "mini"
          },
          {
            name: "取消",
            id: "PersonnelCancellation",
            size: "mini"
          }
        ];
      } else if (this.type === "PersonnelReportingforApproval") {
        this.$nextTick(() => {
          this.$refs.formComponent8.form = this.FilledBy;
        });
        this.dialogConfig2.btnList = [
          {
            name: "同意",
            type: "primary",
            id: "PersonnelReportandAgree",
            size: "mini"
          },
          {
            name: "驳回",
            id: "PersonnelReportRejection",
            size: "mini"
          },
          {
            name: "取消",
            id: "PersonnelCancellation",
            size: "mini"
          }
        ];
      }
    },
    // 人员上报审批
    PersonnelReportingforApproval(id) {
      this.type = "PersonnelReportingforApproval";
      this.titleConfig2 = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "通知信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "参培人员",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        },
        {
          title: "审批信息",
          name: "5",
          slot: "slot5"
        }
      ];
      this.formConfig8 = {
        formData: [{
          type: "input",
          label: "审批意见",
          isDisabled: false,
          prop: "approvalOpinion",
          class: "sjgy",
          lableWidth: "120px"
        },
        {
          type: "input",
          label: "审批人",
          isDisabled: true,
          prop: "approvalUser",
          class: "third",
          lableWidth: "120px"
        },
        {
          type: "input",
          label: "单位及部门",
          isDisabled: true,
          class: "third",
          prop: "approvalDept",
          lableWidth: "120px"
        },
        {
          type: "input",
          label: "审批时间",
          isDisabled: true,
          class: "third",
          prop: "approvalTime",
          lableWidth: "120px"
        }]
      };
      trainingDrillStaffGetMembersByRefId({ pageNum: 1, pageSize: 10, refId: id.id }).then(res => {
        this.personnelConfig.table.tableData = res;
      });
      this.PersonnelApprovalEdit(id);
    },
    // 人员上报编辑
    PersonnelReportingandediting(id) {
      this.type = "PersonnelReportingandediting";
      this.titleConfig2 = [
        {
          title: "基本信息",
          name: "1",
          slot: "slot1"
        },
        {
          title: "通知信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "参培人员",
          name: "3",
          slot: "slot3"
        },
        {
          title: "填报信息",
          name: "4",
          slot: "slot4"
        }
      ];

      trainingDrillStaffGetMembersByRefId({ pageNum: 1, pageSize: 10, refId: id.id }).then(res => {
        this.personnelConfig.table.tableData = res;
      });
      this.PersonnelApprovalEdit(id);
    },
    // 树状选择
    deptChoose(val, item) {
      this.$set(this.form, "organisedUnitId", val[0].orgName);
      this.orgId = val[0].id;
    },
    // 分页
    handleSizeChange(val) {
      this.pageNum = val["current-page"];
      this.pageSize = val["page-size"];
      this.list();
    },
    // 关联年计划
    toTaskDetails(id) {
      this.dialogConfig3.isShow = true;
      trainingYearlyDetail({ id: id }).then(data => {
        this.$refs.formComponent10.form = data;
        this.attachInfo = JSON.parse(data.attachInfo);
        const text = `${data.trainingPeriod}期`;
        this.$set(this.$refs.formComponent10.form, "trainingPeriod", text);
        let projectType = "";
        if (data.projectType === 1) {
          projectType = "年度";
          this.$set(this.$refs.formComponent10.form, "projectType", projectType);
        } else if (data.projectType === 2) {
          projectType = "月度";
          this.$set(this.$refs.formComponent10.form, "projectType", projectType);
        } else if (data.projectType === 3) {
          projectType = "临时";
          this.$set(this.$refs.formComponent10.form, "projectType", projectType);
        }

      });
    },
    // 时间提示
    pickerChanges(val, mum) {
      this.$nextTick(() => {
        if (
          val.planEndTime &&
          val.planStartTime
        ) {
          const start = +new Date(
            val.planStartTime
          );
          const end = +new Date(val.planEndTime);
          if (mum === 1) {
            if (start > end) {
              this.$message({
                message: "开始时间不能大于结束时间",
                type: "error"
              });
              this.$set(this.tables.tableData[0], "planStartTime", "");
            }
          } else {
            if (end < start) {
              this.$message({
                message: "结束时间不能小于开始时间",
                type: "error"
              });
              this.$set(this.tables.tableData[0], "planEndTime", "");

            }
          }
        }
      });
    },
    // 时间提示
    pickerChangesbj(val, mum) {
      this.$nextTick(() => {
        if (
          val.planEndTime &&
          val.planStartTime
        ) {
          const start = +new Date(
            val.planStartTime
          );
          const end = +new Date(val.planEndTime);
          if (mum === 1) {
            if (start > end) {
              this.$message({
                message: "开始时间不能大于结束时间",
                type: "error"
              });
              this.$set(this.tablesbj.tableData[0], "planStartTime", "");
            }
          } else {
            if (end < start) {
              this.$message({
                message: "结束时间不能小于开始时间",
                type: "error"
              });
              this.$set(this.tablesbj.tableData[0], "planEndTime", "");

            }
          }
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
@import "../../../assets/style/common.less";
@import "../../../assets/style/ComponentStyle.less";
@import "../../../assets/style/pop-upNotification.less";

.Download {
  font-size: 17px;
  text-align: right;
  vertical-align: middle;
  float: left;
  color: #606266;
  line-height: 40px;
  padding: 0 12px 0 0;
  box-sizing: border-box;
  margin-left: 70px;
}

.Downloads {
  font-size: 17px;
  text-align: right;
  vertical-align: middle;
  float: left;
  color: #3561fd;
  cursor: pointer;
  text-decoration: underline;
  line-height: 40px;
  padding: 0 12px 0 0;
  box-sizing: border-box;
  margin-left: 10px;
}

:deep(.el-breadcrumb__inner.is-link) {
  font-weight: 100;
  color: #fff;
}

.EmergencyList :deep(.el-breadcrumb__item:last-child .el-breadcrumb__inner) {
  color: #3270ff;
}

.box {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 15px;
  background-color: #fff;
  border-radius: 4px;
  padding: 10px;
  box-sizing: border-box;
}

.yqwcsj {
  :deep(.el-date-editor.el-input, .el-date-editor.el-input__inner) {
    width: auto;
  }
}

:deep(.el-input__inner) {
  font-size: 16px;
}

:deep(.el-select__tags-text) {
  font-size: 16px;
}

:deep(.el-tag__close) {
  background-color: rgba(185, 206, 250) !important;
  color: #333333 !important;
  border-radius: 0px !important;
  height: 25px;
  font-size: 15px !important;
  border: none !important;
}

:deep(.el-tag.el-tag--info) {
  background-color: rgba(185, 206, 250) !important;
  color: #333333 !important;
  border-radius: 0px !important;
  height: 25px;
  font-size: 15px !important;
  border: none !important;
}

.yuandian1 {
  display: inline-block;
  background-color: #ccc;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.ydBgcolor {
  background-color: #246dfd;
  box-shadow: 0px 0px 8px 0px rgb(10, 99, 241);
}

:deep(.el-step__icon.is-text) {
  border: none;
}

:deep(.el-step__title.is-process) {
  font-weight: normal;
}

:deep(.el-input-number--small) {
  width: 100% !important;
}
</style>
